Invalid update: invalid number of items on UICollectionView

前端 未结 7 1015
攒了一身酷
攒了一身酷 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:27

    It's a bug with using insertItemsAtIndexPaths on an empty UICollectionView. Just do this:

    if (self.birthdays.count == 1) {
        [self.collectionView reloadData];
    } else {
        [self.collectionView insertItemsAtIndexPaths:@[[NSIndexPath indexPathForItem:   (self.birthdays.count -1) inSection:0]]];
    }
    

    (Can't believe this is still broken in iOS8.)

提交回复
热议问题