Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/110.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UICollectionView删除单元格工作不正常_Ios_Objective C_Uiviewcontroller_Uicollectionview - Fatal编程技术网

Ios UICollectionView删除单元格工作不正常

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

我的UICollectionView上有120个单元格。当我的查询结束其结果时,我调用以下函数:

[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不会将您带回旧内容。