UICollectionView NSInternalInconsistencyException出现的原因

'NSInternalInconsistencyException', reason: 'UICollectionView received layout attributes for a cell with an index path that does not exist: {length = 2, path = 0 - 0}'

出现这个bug的原因,主要是Collection的DataSource没有设置好,例如
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
返回nil,
或者CollectionView没有设置DataSource,xib没有拖控件。

猜你喜欢

转载自lizhuang.iteye.com/blog/2210101