I am trying to add a footer to a UICollectionView.
Below is my code,
UICollectionView is added via IB
In viewDidLoad I will register a footer,
[mCollectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"footer"];
And the following method is implemented
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath { UICollectionReusableView *reusableview = nil; if (kind == UICollectionElementKindSectionFooter) { UICollectionReusableView *headerView = [mCollectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"footer" forIndexPath:indexPath]; [headerView addSubview:mFooterView]; reusableview = headerView; } return reusableview; }
But my application continues to crash, and below is the log,
*** Validation error in - [UICollectionView _dequeueReusableViewOfKind: withIdentifier: forIndexPath:], / SourceCache / UIKit / UIKit-2380.17 / UICollectionView.m: 2249
Any help is appreciated.
Thanks.
source share