- (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/

10-11 05:05