Ios UICollectionView删除单元格工作不正常
我的UICollectionView上有120个单元格。当我的查询结束其结果时,我调用以下函数:Ios UICollectionView删除单元格工作不正常,ios,objective-c,uiviewcontroller,uicollectionview,Ios,Objective C,Uiviewcontroller,Uicollectionview,我的UICollectionView上有120个单元格。当我的查询结束其结果时,我调用以下函数: [self.collectionView performBatchUpdates:^{ NSIndexPath *indexPath = [NSIndexPath indexPathForRow:92 inSection:0]; [self.collectionView deleteItemsAtIndexPaths: [NSArray arrayWithObjects:indexP
[self.collectionView performBatchUpdates:^{
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:92 inSection:0];
[self.collectionView deleteItemsAtIndexPaths: [NSArray arrayWithObjects:indexPath, nil]];
[self.collectionView reloadData];
// NSIndexPath *indexPath = [NSIndexPath indexPathFor];
// [self.collectionView deleteItemsAtIndexPaths: index];
// [self.collectionView.dataSource removeObjectAtIndex:index]; // First delete the item from you model
// [self.collectionView deleteItemsAtIndexPaths:@[[NSIndexPath indexPathForRow:index inSection:index]]];
}
completion:^(BOOL finished)
{
// Finished
}];
以上内容几乎删除了屏幕上的所有内容。为什么会这样
谢谢。我认为您应该使用indexPathForItem:Instation:来代替UICollectionView。不确定这是否会解决您的问题…您可能需要在删除collectionview中的单元格后更新模型。尝试删除位于单元格的indexPath处的数据。这将确保reloeaddata不会将您带回旧内容。我认为您应该使用indexPathForItem:inSection:来代替UICollectionView。不确定这是否会解决您的问题…您可能需要在删除collectionview中的单元格后更新模型。尝试删除位于单元格的indexPath处的数据。这将确保reloeaddata不会将您带回旧内容。