Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[collections] Add support for supplementary views.

  • Loading branch information...
commit 72a2a59a4dc441cf5d07b089f18e45209363087d 1 parent edb7291
@jverkoey authored
View
6 src/collections/src/NICollectionViewCellFactory.m
@@ -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
View
13 src/collections/src/NICollectionViewModel.h
@@ -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
/**
View
13 src/collections/src/NICollectionViewModel.m
@@ -195,6 +195,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 -
#pragma mark Public Methods
Please sign in to comment.
Something went wrong with that request. Please try again.