2014-07-24 11:50:15.925 *** Assertion failure in -[UICollectionViewData layoutAttributesForSupplementaryElementOfKind:atIndexPath:], /SourceCache/UIKit/UIKit-2935.137/UICollectionViewData.m:787
2014-07-24 11:50:15.927 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'no UICollectionViewLayoutAttributes instance for -layoutAttributesForSupplementaryElementOfKind: UICollectionElementKindSectionFooter at path <NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0}'
当我滚动我的集合视图时,我发生此错误消息,我完全不知道怎么会发生这种情况?任何帮助的建议都要感恩。
寄存器
[self.collectionView registerClass:[CollectionViewFooter class]
forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"CollectionViewFooter"];
代表方法
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
//declare the reusable view of header and footer
UICollectionReusableView *reusableview = nil;
CollectionViewFooter *footer=nil;
if([kind isEqual:UICollectionElementKindSectionFooter])
{
footer = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"CollectionViewFooter" forIndexPath:indexPath];
//attach the footer to reusable view
reusableview = footer;
}
return reusableview;
}
按断点检查,到达线路时发生错误
[self.collectionView performBatchUpdates:^{