你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> IOS 集合視圖指南1:介紹

IOS 集合視圖指南1:介紹

編輯:IOS開發綜合

About iOS Collection Views(關於IOS集合視圖)

A collection view is a way to present an ordered set of data items using a flexible and changeable layout. The most common use for collection views is to present items in a grid-like arrangement, but collection views in iOS are capable of more than just rows and columns. With collection views, the precise layout of visual elements is definable through subclassing and can be changed dynamically, so you can implement grids, stacks, circular layouts, dynamically changing layouts, or any type of arrangement you can imagine.

Collection views keep a strict separation between the data being presented and the visual elements used to present that data. In most cases, your app is solely responsible for managing the data. Your app also provides the view objects used to present that data. After that, the collection view takes your views and does all the work of positioning them onscreen. It does this work in conjunction with a layout object, which specifies the placement and visual attributes for your views and that can be subclassed to fit your app’s exact needs. Thus, you provide the data, the layout object provides the placement information, and the collection view merges the two pieces together to achieve the final appearance.


集合視圖是一種通過靈活多變的布局展現有序數據項的方法。通常集合視圖把數據展示成網狀,但是IOS中的集合視圖能勝任的遠遠不止行和列。集合視圖可以通過子類化來實現元素的精確定位和動態更改,於是你可以實現網站,棧形,循環以及任何你能想到的各種布局。
集合視圖保證了界面和數據的嚴格分離。在大部分情況下,你的應用只需要負責管理數據。然後,集合視圖會完成你所有的界面布局任務。集合視圖和布局對象一起完成這些工作,布局對象指定了你的視圖的位置和市局屬性,你可以通過子類化布局對象來實現你的應用的切實需求。於是呢,你提供的數據信息,布局對象提供的位置信息,由集合視圖綜合起來實現最終的展示效果。

At a Glance(概覽)

The standard iOS collection view classes provide all of the behavior you need to implement simple grids. You can also extend the standard classes to support custom layouts and specific interactions with those layouts.

標准的IOS集合視圖類提供了你實現一個簡單網格的所有行為。當然你也可以拓展標准類以支持自定義布局和那些相互作用的布局。

 

A Collection View Manages the Visual Presentation of Data-Driven Views

A collection view facilitates the presentation of data-driven views provided by your app. The collection view’s only concern is taking your views and laying them out in a specific way. The collection view is all about the presentation and arrangement of your views and not about their content. Understanding the interactions between the collection view, its data source, the layout object, and your custom objects is crucial for using collection views in your app, particularly in smart and efficient ways.

Relevant chapters: Collection View Basics, Designing Your Data Source and Delegate

 

集合視圖控制視覺展現(數據—驅動—視圖)

 

集合視圖便於展示由應用程序提供的數據驅動的視圖。集合視圖只關心獲取你的視圖並且把他們按照特定的方式布局。集合視圖只關心如何展示和安排你的視圖並不關系視圖中的內容。理解視圖之間的相互關系,數據源,布局對象,和你的自定義對象是在你的應用裡面使用的集合視圖的關鍵,特別是智能和有效方法。

 

相關章節:集合視圖基礎,設計你的數據源和代理

 

 

The Flow Layout Supports Grids and Other Line-Oriented Presentations

 

A flow layout object is a concrete layout object provided by UIKit. You typically use the flow layout object to implement grids—that is, rows and columns of items—but the flow layout supports any type of linear flow. Because it is not just for grids, you can use the flow layout to create interesting and flexible arrangements of your content both with and without subclassing. The flow layout supports items of different sizes, variable spacing of items, custom headers and footers, and custom margins without subclassing. And subclassing allows you to tweak the behavior of the flow layout class even further.


支持網格和其他線性展示的流動布局

流動布局對象是UIKit框架提供的一個具體的布局對象。通常情況下,你可以使用流動布局對象來實現網格(由行列元素組成),但是流動布局對象支持任何類型的流線型布局。因為流動布局不僅僅支持網絡布局,不管你使用不使用子類化,你都可以使用流動布局創建流暢有趣的內容排布。在沒有子類化的情況下流動布局可以支持,不同尺寸的元素,他們之間變化的距離,自定義頁眉頁腳,和自定義的邊界。通過子類化你可以把流動布局類調整的更加強大。

 

Relevant chapter: Using the Flow Layout

 

相關章節:使用流動布局

Gesture Recognizers Can Be Used for Cell and Layout Manipulations

Like all views, you can attach gesture recognizers to a collection view to manipulate the content of that view. Because a collection view involves the collaboration of multiple views, it helps to understand some basic techniques for incorporating gesture recognizers into your collection views. You can use gesture recognizers to tweak layout attributes or to manipulate items in a collection view.

手勢操作可以使用在單元格和布局操作中
就像所有視圖一樣 ,你可以給集合視圖添加手勢識別來操控諸多內容視圖。因為集合視圖牽涉了多視圖的協作,這會幫助你理解集合視圖之中多個視圖協作的基本技術。你可以使用手勢識別來調整集合視圖中的布局屬性和操作視圖中的元素。

 

 


Relevant chapter: Incorporating Gesture Support

 

相關章節:結合手勢支持

 

 

Custom Layouts Let You Go Beyond Grids(自定義布局讓你超越網格布局)

You can subclass the basic layout object to implement custom layouts for your app. Even though designing a custom layout does not typically require a large amount of code, the more you understand how layouts work, the better you can design your layout objects to be efficient. The guide’s final chapter focuses on an example project with a full implementation of a custom layout.

Relevant chapters: Creating Custom Layouts, Custom Layouts: A Worked Example

 

你可以子類化基礎布局對象來實現讓你的應用自定義布局。盡管通常情況下自定義布局並不需要大量代碼,但是你越理解布局是怎樣工作的,你設計的布局對象就越有效。在指南的最後一章節,我們集中來看一個完整的自定義布局的項目范例。

 

 

相關章節:創建自定義布局,自定義布局:一個實例。

 

 

Prerequisites(先決條件)

 

Before reading this document, you should have a solid understanding of the role views play in iOS apps. If you are new to iOS programming and not familiar with the iOS view architecture, read View Programming Guide for iOS before reading this book.

在閱讀這篇文檔之前,你應該對視圖在IOS中扮演一個怎樣的角色有一個深刻的理解。如果你是一個IOS編程新手同時不了解IOS中視圖的結構,請在閱讀本書之前讀《IOS 視圖編程指南》。

 

 

See Also(另見)

 

Collection views are somewhat related to table views, in that both present ordered data to the user. The implementation of a table view is similar to that of a standard collection view (one which uses the provided flow layout) in its use of index paths, cells, and view recycling. However, the visual presentation of table views is geared around a single-column layout, whereas collection views can support many different layouts. For more information about table views, seeTable View Programming Guide for iOS.

集合視圖和表示圖有些關系,他們都是展示有序的用戶數據。實現一個表示圖和實現一個標准的集合視圖(使用流動布局提供的)在indexPaths,cell,和視圖復用上非常類似。盡管如此,tableView的展現形式是單列布局,而集合視圖支持多種布局。更多信息參見《IOS表視圖編程指南》

 

 

 

 

 

 

 

 



  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved