PageMenu错误,UICollectionView接收具有不存在的索引路径的单元格的布局属性

时间:2015-07-25 09:54:09

标签: ios swift uicollectionviewlayout collectionview

我使用PageMenu,滑动过渡库。
https://github.com/uacaps/PageMenu

当我转换新的collectionViewController时,它很好。

但是当我滑回现有的collectionViewController时,它总是崩溃。

我读了其他stackoverflow帖子,发现了两个解决方案。我尝试了这些解决方案,但它崩溃了。

第一个解决方案

override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
    collectionView.collectionViewLayout.invalidateLayout()
    return 1
}

第二个解决方案

override func viewWillAppear(animated: Bool) {
    collectionView?.collectionViewLayout.invalidateLayout()
    collectionView?.reloadData()
}

错误日志

有什么问题?

 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UICollectionView received layout attributes for a cell with an index path that does not exist: <NSIndexPath: 0xc000000000018016> {length = 2, path = 0 - 3}'

0 个答案:

没有答案