Trying to add a a Supplementary view into my UICollectionView
as a header. I\'m having issues getting it to work.
I use a custom UICollectionViewFlowL
I was having the same issue and similarly, I was not registering the header correctly. there are several threads on here that all suggest using a Nib to define the header but I have done it differently and is working fine.
I have a custom header SizeCollectionHeader, which inherits the UICollectionReusableView. It is registered like this.
[self.collectionView registerClass:[GRSizeCollectionHeader class] forSupplementaryViewOfKind:@"UICollectionElementKindSectionHeader"
withReuseIdentifier:@"SupplementaryViewIdentifier"];
and is working fine.
my initial problem was that had a random "Kind" value like this.
[self.collectionView registerClass:[GRSizeCollectionHeader class] forSupplementaryViewOfKind:@"SupplementaryViewKind"
withReuseIdentifier:@"SupplementaryViewIdentifier"];
This will crash.
So I just wanted to comment for anybody that is looking here that you don't need to use a nib.