NimbusKit
1.2.1 - Fork Nimbus on Github - Visit the Nimbus Wiki
The iOS framework that grows only as fast as its documentation
|
A simple factory for creating collection view cells from objects.
This factory provides a single method that accepts an object and returns a UICollectionViewCell for use in a UICollectionView. A cell will only be returned if the object passed to the factory conforms to the NICollectionViewCellObject protocol. The created cell should ideally conform to the NICollectionViewCell protocol. If it does, the object will be passed to it via shouldUpdateCellWithObject: before the factory method returns.
This factory is designed to be used with NICollectionViewModel, though one could easily use it with other collection view data source implementations simply by providing nil for the collection view model argument.
If you instantiate an NICollectionViewCellFactory then you can provide explicit mappings from objects to cells. This is helpful if the effort required to implement the NICollectionViewCell protocol on an object outweighs the benefit of using the factory, i.e. when you want to map simple types such as NSString to cells.
Tasks | |
(UICollectionViewCell *) | + collectionViewModel:cellForCollectionView:atIndexPath:withObject: |
(void) | - mapObjectClass:toCellClass: |
(Class) | - collectionViewCellClassForItemAtIndexPath:model: |
(Class) | + collectionViewCellClassForItemAtIndexPath:model: |
(UICollectionReusableView *) | - collectionViewModel:collectionView:viewForSupplementaryElementOfKind:atIndexPath: |
Creates a cell from a given object if and only if the object conforms to the NICollectionViewCellObject protocol.
This method signature matches the NICollectionViewModelDelegate method so that you can set this factory as the model's delegate:
If you would like to customize the factory's output, implement the model's delegate method and call the factory method. Remember that if the factory doesn't know how to map the object to a cell it will return nil.
Reimplemented from <NICollectionViewModelDelegate>.
Map an object's class to a cell's class.
If an object implements the NICollectionViewCell protocol AND is found in this factory mapping, the factory mapping will take precedence. This allows you to explicitly override the mapping on a case-by-case basis.
Returns the mapped cell class for an object at a given index path.
Explicitly mapped classes in the receiver take precedence over implicitly mapped classes.
This method is helpful when implementing layout calculation methods for your collection view. You can fetch the cell class and then perform any selectors that are necessary for calculating the dimensions of the cell before it is instantiated.
Returns the mapped cell class for an object at a given index path.
This method is helpful when implementing layout calculation methods for your collection view. You can fetch the cell class and then perform any selectors that are necessary for calculating the dimensions of the cell before it is instantiated.
Fetches a supplementary collection view element at a given indexPath.
The value of the kind property and indexPath are implementation-dependent based on the type of UICollectionViewLayout being used.