首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >-[UICollectionView _endItemAnimations]中的UICollectionView断言失败

-[UICollectionView _endItemAnimations]中的UICollectionView断言失败
EN

Stack Overflow用户
提问于 2015-03-23 12:50:07
回答 1查看 443关注 0票数 0

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

代码语言:javascript
复制
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).

如果我把它改成reloadData没有问题,但这并不理想。

如果我分几次调用它,它就会崩溃。如果只有一次,那么没有任何问题。

我是不是漏掉了什么?我以为数字是匹配的?这里的问题是什么?

EN

回答 1

Stack Overflow用户

发布于 2015-03-25 01:07:11

你能确认你真的在insertItemsAtIndexPaths:调用中崩溃了吗?假设是,错误代码明确地告诉您,当您在集合视图上调用insertItemsAtIndexPaths:时,该节中的项数没有变化。你能发布你的集合视图数据源方法(例如collectionView:numberOfItemsInSection:),这样我们就可以确认你是否正确地处理了它?

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29203456

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档