UICollectionView Tutorial Example in iOS 6 – Xcode 4.5 pt1
This tutorial we introduce the UICollectionView controller. If you’re not familiar the UICollectionView see the basic definition below. So, we start by implementing the collectionview controller into our storyboard. Then we setup a custom cell with an imageview to be displayed within the collectionview cell and finally create classes to handle the view controller and custom collectionview cell. The resources section below has the project files that can be downloaded.
UICollectionView class manages an ordered collection of data items and presents them using customizable layouts. Collection views provide the same general function as table views except that a collection view is able to support more than just single-column layouts. Collection views support customizable layouts that can be used to implement multi-column grids, tiled layouts, circular layouts, and many more. You can even change the layout of a collection view dynamically if you want.
When adding a collection view to your user interface, your app’s main job is to manage the data associated with that collection view. The collection view gets its data from the data source object, which is an object that conforms to the
UICollectionViewDataSourceprotocol and is provided by your app. Data in the collection view is organized into individual items, which can then be grouped into sections for presentation. An item is the smallest unit of data you want to present. For example, in a photos app, an item might be a single image. The collection view presents items onscreen using a cell, which is an instance of the
UICollectionViewCell class that your data source configures and provides.
In addition to its cells, a collection view can present data using other types of views too. These supplementary views can be things like section headers and footers that are separate from the individual cells but still convey some sort of information. Support for supplementary views is optional and defined by the collection view’s layout object, which is also responsible for defining the placement of those views.
Besides embedding it in your user interface, you use the methods of
UICollectionView object to ensure that the visual presentation of items matches the order in your data source object. Thus, whenever you add, delete, or rearrange data in your collection, you use the methods of this class to insert, delete, and rearrange the corresponding cells. You also use the collection view object to manage the selected items, although for this behavior the collection view works with its associated