TLCollectionViewController Class Reference
Inherits from | UICollectionViewController |
Conforms to | TLIndexPathControllerDelegate |
Declared in | TLCollectionViewController.h |
Overview
A subclass of UICollectionViewController
that works with TLIndexPathController
and provide default impelementations of the essential data source and delegate
methods to get your collection views up-and-running as quickly as possible.
This class also supports view controller-backed cells.
Properties
indexPathController
The collection view’s index path controller. A default controller is
created automatically with nil
for identifierKeyPath
, sectionNameKeyPath
.
It is not uncommon to replace this default instance with a custom
controller. For example, if Core Data is being used, one would
typically provide a controller created with the
initWithFetchRequest:managedObjectContext:sectionNameKeyPath:identifierKeyPath:cacheName:
initializer.
@property (strong, nonatomic) TLIndexPathController *indexPathController
Declared In
TLCollectionViewController.h
Instance Methods
collectionView:cellIdentifierAtIndexPath:
The implementation of collectionView:cellForItemAtIndexPath:
calls this method
to ask for the cell’s identifier before attempting to dequeue a cell. The default
implementation of this method first asks the data model for an identifier and,
if none is provided, returns the “Cell”. Data models that don’t use
TLIndexPathItem
as their item type typically return nil
and so it is not
uncommon to override this method with custom logic.
- (NSString *)collectionView:(UICollectionView *)collectionView cellIdentifierAtIndexPath:(NSIndexPath *)indexPath
Declared In
TLCollectionViewController.h
collectionView:configureCell:atIndexPath:
- (void)collectionView:(UICollectionView *)collectionView configureCell:(UICollectionViewCell *)cell atIndexPath:(NSIndexPath *)indexPath
collectionView:instantiateViewControllerForCell:atIndexPath:
This method should be overridden to enable view controller-backed cells. The default
implementation returns nil
. If this method returns a view controller for the given
cell and index path, the table view controller will automatically install the backing
controller as a child view controller in cellForItemAtIndexPath
and uninstall it
in collectionView:didEndDisplayingCell:forItemAtIndexPath:
. This method is responsible
for installing the view controller’s view into the cell’s view heirarchy.
- (UIViewController *)collectionView:(UICollectionView *)collectionView instantiateViewControllerForCell:(UICollectionViewCell *)cell atIndexPath:(NSIndexPath *)indexPath
Declared In
TLCollectionViewController.h
collectionView:viewControllerForCell:
Returns the backing view controller for the given cell, if any. This method is used
internally and can also be called in custom code, for example when configuring the
cell in cellForItemAtIndexPath
. To enable view controller-backed cells, override
the companion method collectionView:instantiateViewControllerForCell:atIndexPath:
.
- (UIViewController *)collectionView:(UICollectionView *)collectionView viewControllerForCell:(UICollectionViewCell *)cell
Declared In
TLCollectionViewController.h