在某些事件中,
我想删除 uicollectionview 中的所有单元格,并添加新单元格。(将作为网络调用的结果填充)
我尝试使用 deleteItemsAtIndexPaths。重新加载部分,删除部分/插入部分。
他们每个人都使我的应用程序崩溃。
下面是我的代码。
NSMutableArray* indexPathArray = [[NSMutableArray alloc] init];
for(int i=0; i < [self.jsonAlbumImageArray count]; ++i)
{
NSIndexPath* newPath = [NSIndexPath indexPathForRow:i inSection:0];
[indexPathArray addObject: newPath];
}
[self.jsonAlbumImageArray removeAllObjects];
if(indexPathArray.count > 0 )
{
[self.collectionView performBatchUpdates:^{
[self.collectionView deleteItemsAtIndexPaths:indexPathArray];
}
completion: nil];
}
// NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 1)];
// NSIndexSet* indexSet = [NSIndexSet indexSetWithIndex:0];
// [self.collectionView reloadSections:indexSet];
[self get_IMAGE_LIST_FROM_SERVER];