Skip to content

Commit

Permalink
[collections] Add support for supplementary views.
Browse files Browse the repository at this point in the history
  • Loading branch information
jverkoey committed Apr 2, 2013
1 parent edb7291 commit 72a2a59
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/collections/src/NICollectionViewCellFactory.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ + (UICollectionViewCell *)cellWithClass:(Class)collectionViewCellClass

///////////////////////////////////////////////////////////////////////////////////////////////////
+ (UICollectionViewCell *)collectionViewModel:(NICollectionViewModel *)collectionViewModel
cellForCollectionView:(UICollectionView *)collectionView
atIndexPath:(NSIndexPath *)indexPath
withObject:(id)object {
cellForCollectionView:(UICollectionView *)collectionView
atIndexPath:(NSIndexPath *)indexPath
withObject:(id)object {
UICollectionViewCell* cell = nil;

// If this assertion fires then your app is about to crash. You need to either add an explicit
Expand Down
13 changes: 13 additions & 0 deletions src/collections/src/NICollectionViewModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@
atIndexPath:(NSIndexPath *)indexPath
withObject:(id)object;

@optional

/**
* 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.
*/
- (UICollectionReusableView *)collectionViewModel:(NICollectionViewModel *)collectionViewModel
collectionView:(UICollectionView *)collectionView
viewForSupplementaryElementOfKind:(NSString *)kind
atIndexPath:(NSIndexPath *)indexPath;

@end

/**
Expand Down
13 changes: 13 additions & 0 deletions src/collections/src/NICollectionViewModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,19 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell
}


///////////////////////////////////////////////////////////////////////////////////////////////////
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
if ([self.delegate respondsToSelector:
@selector(collectionViewModel:collectionView:viewForSupplementaryElementOfKind:atIndexPath:)]) {
return [self.delegate collectionViewModel:self
collectionView:collectionView
viewForSupplementaryElementOfKind:kind
atIndexPath:indexPath];
}
return nil;
}


///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma mark -
Expand Down

0 comments on commit 72a2a59

Please sign in to comment.