I am getting the following error implementing the supplementary Header View
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'no UICollectionViewLayoutAttributes instance for -layoutAttributesForSupplementaryElementOfKind: HeaderView at path <NSIndexPath: 0x9e82a40> {length = 2, path = 0 - 0}'
This is the code that is creating header view
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
static NSString * headerIdentifier = @"HeaderView";
UICollectionReusableView *header = [collectionView dequeueReusableSupplementaryViewOfKind:headerIdentifier withReuseIdentifier:UICollectionElementKindSectionHeader forIndexPath:indexPath];
return header;
}
The error happens in dequeueReusableSupplementaryViewOfKind method.
I have added these two lines in my initWithCoder of the Collection View Controller
UINib *headerNib = [UINib nibWithNibName:@"MTCollectionHeaderView" bundle:nil];
[self.collectionView registerNib:headerNib forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView"];
so it does have a reference to the UI element. I cannot find anyway to set the layout on the header.
I tried adding this to the same Collection View Controller but it never hit this code as I confirmed by putting a debugger there
- (UICollectionViewLayoutAttributes *)layoutAttributesForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
return [self.collectionViewLayout layoutAttributesForDecorationViewOfKind:kind atIndexPath:indexPath];
}
Has anyone seen this issue and how did they resolve it. Also I am using XCode 5 Developer Preview 5 and developing for iOS7