Assertion Failure in UICollectionViewData indexPathForItemAtGlobalIndex

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

    Finally! Ok, here's what was causing this crash for me.

    As previously noted, I was creating supplementary views in order to provide custom-styled section headers for my collection view.

    The problem is this: it appears that the indexPath of a supplementary view MUST correspond to the indexPath of an extant cell in the collection. If the supplementary view's index path has no corresponding ordinary cell, the application will crash. I believe that the collection view attempts to retrieve information for a supplementary view's cell for some reason during the update procedure. It crashes when it cannot find one.

    Hopefully this will solve your problem too!

提交回复
热议问题