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\u endItemAnimations]中的UICollectionView断言失败_Ios_Objective C_Uicollectionview - Fatal编程技术网

Ios -[UICollectionView\u endItemAnimations]中的UICollectionView断言失败

Ios -[UICollectionView\u endItemAnimations]中的UICollectionView断言失败,ios,objective-c,uicollectionview,Ios,Objective C,Uicollectionview,长话短说,我只是这么做: NSIndexPath *indexPath = [NSIndexPath indexPathForItem:insPoint inSection:0]; [self.m_orders insertObject:orderRecord atIndex:insPoint]; [self.m_collectionView insertItemsAtIndexPaths:[NSArray arrayWithObject:indexPath]]; Invalid updat

长话短说,我只是这么做:

NSIndexPath *indexPath = [NSIndexPath indexPathForItem:insPoint inSection:0];
[self.m_orders insertObject:orderRecord atIndex:insPoint];
[self.m_collectionView insertItemsAtIndexPaths:[NSArray arrayWithObject:indexPath]];


Invalid update: invalid number of items in section 0.  The number of items contained in an existing section after the update (2) must be equal to the number of items contained in that section before the update (2), plus or minus the number of items inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out).
如果我将其更改为重新加载数据,则没有问题,但这并不理想

如果我连续几次调用它,它就会崩溃。如果只有一次,那就没有问题了


我是不是遗漏了什么?我以为数字匹配?这里会出现什么问题?

您能否确认您确实在中断insertItemsAtIndexPaths:call?假设是,错误代码明确地告诉您,在集合视图上调用insertItemsAtIndexPaths:时,该部分中的项目数没有改变。你能发布你的收集视图数据源方法如collectionView:numberOfItemsInSection:这样我们就可以确认你处理的正确吗

另外,你能确认这一切都发生在主线程上吗?如果是这样,这里发生了两件事之一: 1在命中此代码之前,您正在其他地方修改数据源。
2在点击此代码之前,您正在执行其他集合视图更新插入/删除。

参考链接,该链接提供了与您的问题相关的信息是的,我正在中断该呼叫。-NSIntegercollectionView:UICollectionView*查看numberofitemsinssection:NSIntegersection{return self.m_orders.count;}所有这些都发生在主线程上。正如您所说的,我相信可能有一些数据在其他地方以self.m_顺序移动并删除了一个对象,因此当插入代码被命中时,会出现错误。不过,当我有时间的时候,我必须仔细看看,因为现在我正在使用重载数据。非常感谢你对它为什么会坏的建议!!