The code below displays my header view correctly, but for each of the sections in the UICollectionView:
-(UICollectionReusableView *)collectionView:(UICollectionView *)collectionView
viewForSupplementaryElementOfKind:(NSString *)kind
atIndexPath:(NSIndexPath *)indexPath {
UICollectionReusableView * headerView =
[collectionView
dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader
withReuseIdentifier:@"SectionHeaderCollectionReusableView"
forIndexPath:indexPath];
switch (indexPath.section) {
case Section_One:
return headerView;
case Section_Two:
return headerView;
case Section_Three:
return headerView;
case Section_Four:
return headerView;
case Section_Five:
return headerView;
default:
return headerView;
}
}
What I would like to do instead, is not display a header view for 'Section_One' or 'Section_Two', but returning 'nil' results in an 'NSInternalInconsistencyException':
-(UICollectionReusableView *)collectionView:(UICollectionView *)collectionView
viewForSupplementaryElementOfKind:(NSString *)kind
atIndexPath:(NSIndexPath *)indexPath {
UICollectionReusableView * headerView =
[collectionView
dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader
withReuseIdentifier:@"SectionHeaderCollectionReusableView"
forIndexPath:indexPath];
switch (indexPath.section) {
case Section_One:
return nil;
case Section_Two:
return nil;
case Section_Three:
return headerView;
case Section_Four:
return headerView;
case Section_Five:
return headerView;
default:
return nil;
}
}
What do I need to do to display a header view for only certain sections?