Permalink
Browse files

[collections] Add support for supplementary views.

  • Loading branch information...
1 parent edb7291 commit 72a2a59a4dc441cf5d07b089f18e45209363087d @jverkoey committed Apr 2, 2013
@@ -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
@@ -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
/**
@@ -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

0 comments on commit 72a2a59

Please sign in to comment.