
文档似乎很缺乏,但它涵盖了一个案例:
Deletes are processed before inserts in batch operations. This means
the indexes for the deletions are processed relative to the indexes of
the collection vIEw’s state before the batch operation,and the
indexes for the insertions are processed relative to the indexes of
the state after all the deletions in the batch operation.
但是,该文档没有讨论何时处理移动.如果我在同一个performBatchUpdates中调用moveItemAtIndexPath和deleteItemsAtIndexPaths,那么移动索引是否应该相对于删除前或删除后的订单? insertItemsAtIndexPaths怎么样?
最后,我遇到了在同一 *** 作中调用reloadItemsAtIndexPaths和moveItemAtIndexPath的问题:
Fatal Exception: NSInternalinconsistencyException attempt to delete
and reload the same index path
有没有办法在同一个performBatchUpdates中执行我想要的所有 *** 作?如果是,那么更新相对于其他更新的处理顺序是什么?如果没有,人们通常会做什么?在完成所有其他 *** 作后重新加载数据?之前?如果所有的动画都发生在一个阶段,我更喜欢.
解决方法 对于移动 *** 作,from indexPath是预删除索引,to indexPath是删除后索引.仅应为尚未插入,删除或移动的indexPath指定重新加载.这可能是您看到NSInternalinconsistencyException的原因.验证 *** 作的一种方便的方法是正确设置的:重新加载,插入和移动到索引路径的集合不应该有任何重复,并且重新加载,删除和移动索引路径的集合不应该有任何重复.
更新:
您移动的项目似乎也未更新,但仅移动.因此,如果需要更新和移动项目,可以在批量更新之前或之后执行重新加载(取决于数据源的状态).
总结以上是内存溢出为你收集整理的ios – 如何在UICollectionView performBatchUpdates块中对移动,插入,删除和更新进行排序?全部内容,希望文章能够帮你解决ios – 如何在UICollectionView performBatchUpdates块中对移动,插入,删除和更新进行排序?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)