Assertion Failure in UICollectionViewData indexPathForItemAtGlobalIndex

后端 未结 8 2068
南旧
南旧 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:51

    I ran into this problem when I delete one of the cells from my collection view.

    The problem was that I use a custom layout, and the call layoutAttributesForElementsInRect was returning more than the number of cells in the collection view after the delete.

    Apparently UICollectionView just iterates through the array returned by the method without checking the number of cells.

    Modifying the method to return the same number of layout attributes solved the crash.

提交回复
热议问题