I get the following error implementing an optional header
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 creates the 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 occurs in the dequeueReusableSupplementaryViewOfKind method.
I added these two lines to my initWithCoder collection controller.
UINib *headerNib = [UINib nibWithNibName:@"MTCollectionHeaderView" bundle:nil]; [self.collectionView registerNib:headerNib forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView"];
therefore, it has a link to a user interface element. I just can't find the layout in the title.
I tried to add this to the same Control View Controller, but I never hit this code, as I confirmed by setting the debugger there
- (UICollectionViewLayoutAttributes *)layoutAttributesForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath { return [self.collectionViewLayout layoutAttributesForDecorationViewOfKind:kind atIndexPath:indexPath]; }
Has anyone seen this problem and how they solved it. I also use Xcode 5 Developer Preview 5 and develop for iOS7
source share