
UICollectionView is a direct subclass of UIScrollView, much like UITableView. Similarly to the UICollectionView inheritance, the UICollectionViewDelegate protocol conforms to the UIScrollViewDelegate protocol. In practical terms, this means that if an object is the delegate of a collection view, it receives callbacks notifying it of UICollectionViewDelegate events as well as UIScrollViewDelegate events.
Similar to a UITableViewCellinUITableView.
UICollectionView relies on its dataSource to tell it how many cells to display and to configure each individual cell before it is presented to the user.
For every type of cell that’s going to be displayed, you should use a cell reuse identifier. This is an NSString that you typically store as a static variable. Before any cell with that reuse identifier can be displayed, it needs to be registered with the collection view. This is a big departure from UITableView. You usually register cells in viewDidLoad and don’t reregister them later on.


Supplementary views are views that scroll with the cells of a collection view and display some kind of information about the data of that collection.
UICollectionViewFlow is a direct subclass lays out content in line-based, line-breaking style.
The collection view relies on its layout to tell it how to display its cells.
This is a key concept: Layout content is not done by subclassing UICollectionView. Although this is a common pattern for layout subviews when subclassing UIScrollView, we’re going to avoid subclassing UICollectionView unless absolutely necessary.
Layout object about how to display the cells, supplementary views, and decoration views. This information is stored in instances of a class called UICollectionViewLayoutAttributes.
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect
Returns the layout attributes for all of the cells and views in the specified rectangle.
- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath
Returns the layout attributes for the item at the specified index path.