- (void)deleteCell
{
[self.collectionViewMenu performBatchUpdates:^{
[self.itemsArray removeObjectAtIndex:1];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:1 inSection:0];
[self.collectionViewMenu deleteItemsAtIndexPaths:@[indexPath]];
} completion:^(BOOL finished) { }];
}
请帮忙解决这个问题,我做错了什么?尝试删除 collectionView 中的项目后出现此错误。
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: <_UICollectionViewItemKey: 0x8d705e0> Type = SV Kind = UICollectionElementKindSectionHeader IndexPath = <NSIndexPath: 0x8d6f4b0> {length = 2, path = 0 - 0})'
最佳答案
我通过删除页眉和页脚大小代表解决了这个问题。问题在于我没有返回页眉或页脚。
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section;
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section;
关于ios - UICollectionView deleteItemsAtIndexPaths 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18954295/