Invalid update: invalid number of items on UICollectionView

前端 未结 7 1019
攒了一身酷
攒了一身酷 2020-12-07 21:07

I am stumped on this. Here is my scenario. In my Appdelegate, I am creating

  1. An instance of a view controller that will be presented modally to collect two pi
7条回答
  •  天命终不由人
    2020-12-07 21:20

    As for me the issue was connected to the Index Set - where to insert sections. 1. I've inserted Sections 0..<10 (10 sections) 2. I was trying to insert Sections to IndexSet 9..<19. But appending the new objects to the end of the dataSource array. Correct Index set should be (10..<20)

    Thus the last section was still expecting the number of rows from Section 9. But in data source - it was at index 19.

    collectionView?.insertSections(IndexSet(integersIn: startIndex..<(startIndex + series.count)))

提交回复
热议问题