Assertion Failure in UICollectionViewData indexPathForItemAtGlobalIndex

后端 未结 8 2048
南旧
南旧 2020-12-15 04:15

I am using performBatchUpdates() to update my collection view, where I am doing a complete refresh, i.e. delete whatever was in it and re-insert everything.

8条回答
  •  感情败类
    2020-12-15 04:56

    I have been having the same problem.

    I have tried a number of variations, but the final one that seems to work is [self.collectionView reloadData], where "self.collectionView"is the name of your collection view.

    I have tried the following methods, straight from the "UICollectionView Class Reference": inserting, moving, and deleting items.

    These were used at first, to "move" the item from one section to another.

    • deleteItemsAtIndexPaths:

    • insertItemsAtIndexPaths:

    Next, I tried moveItemAtIndexPath:toIndexPath:.

    They all produced the following error:

    Assertion failure in -[UICollectionViewData indexPathForItemAtGlobalIndex:], /SourceCache/UIKit_Sim/UIKit-2372/UICollectionViewData.m:442

    So, try the "reloadData" method.

提交回复
热议问题