在 numberOfItemsInSection returns 非零项目编号后未调用 UICollectionView cellForItemAtIndexPath

UICollectionView cellForItemAtIndexPath not called after numberOfItemsInSection returns nonzero item number

numberOfItemsInSection 被调用并且 returns 一个非零数字后,cellForItemAtIndexPath 不会被调用有什么原因吗?来自完成块的 reloadData 会影响这个吗?我 运行 遇到一个问题,我试图通过 UIAlertController 删除一个单元格并且 UI 看起来不错,但是当我在 reloadData 之后转到 reloadData =30=] 动画结束 numberOfItemsInSection 正确地调用了正确数量的元素(之前的元素数量减去 1),但是 cellForItemAtIndexPath 没有被调用,所以我的单元格没有被重新加载。关于为什么会发生这种情况的任何想法?

这是在 Swift 1.2XCode 6.4 上进行的,如有任何帮助,我们将不胜感激

只是为了提供更多信息,我用来删除单元格的方法看起来有点像:

self.collectionView.performBatchUpdates({
    let indexPathCellToDelete = self.indexPath(feedCell)
    self.collectionView.deleteItemsAtIndexPaths([indexPathCellToDelete])
}, completion:nil)

在完成块中进行第二次重新加载会改变什么吗?

原来 performBatchUpdates,根据 UICollectionView Performing Updates using performBatchUpdates 需要在我的数据源更改完成后调用。但问题是,我从数据源中删除项目的方法本身会重新加载集合视图,因此有一个不需要发生的额外重新加载,这似乎是导致问题的原因。我最初在 performBatchUpdates 的完成块中调用了我的数据源删除方法,但将其移到上面并重新加载整个集合视图似乎已经解决了这个问题。在我的情况下,似乎是一个奇怪的竞争条件,同时发生多个重新加载并且 cellForItemAtIndexPath 不喜欢这样。