I have a UICollectionView
. I would like to add a header. My header would only be a UILabel
. I've :
1) selected "Section Header" as a Collection View accessory in the IB.
2) created a Collection Reusable View in the IB, on the side, declared as collectionViewHeader
.
3) added those lines :
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
if (kind == UICollectionElementKindSectionHeader) {
return collectionViewHeader;
}
return nil;
}
But they are never called.
Do I have to create a class just for that label in order to use
[self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"header"];
?
Why isn't it as simple as the UITableView
where you just drag and drop whatever header you want ?! Things are so complicated with UICollectionView
...