ios - UICollectionView deleteItemsAtIndexPaths 失败

标签 ios objective-c

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

相关文章:

ios - 如何使用 Kaltura 在 iOS (iPhone/iPad) 中实现视频直播?

objective-c - 通用 iOS 应用程序中的 iPad/iPhone 应用程序委托(delegate)有什么意义?

objective-c - 如何在 Objective-C(适用于 iOS)中获取两个字符串之间的第一个不同字符?

iphone - 恢复 NSUserDefault 中的值

objective-c - 比较在不使用 rawValue 的情况下在 Swift 中包装 NS_ENUM 的 NSNumber 属性

ios - OpenSSL 从控制台命令到函数

ios - 添加观察在 Swift 4 中不起作用

ios - 在 objective-c 中访问 SpringBoardServices.h 方法?

ios - 在背景中使用与主要 UIImage 颜色相同的颜色覆盖 UIView

iphone - iPad App - 以编程方式更改语言