iOS Collectionview报错

一直报错:

Assertion failure in -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3698.33.6/UICollectionView.m:5279

2018-07-31 16:14:48.998991+0800 Treasure[27863:33202992] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier HomeOptionCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'

xx,不相信了
使用registerClass,registerNib都正确,最终是继承关系的父类有问题,折腾1小时,不要怀疑自己。向上找问题
[self.m_CollectionView registerClass:[HomeOptionCell class] forCellWithReuseIdentifier:@"HomeOptionCell"];

[self.m_CollectionView registerNib:[UINib nibWithNibName:NSStringFromClass([HomeOptionCell class]) bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"HomeOptionCell"];

你可能感兴趣的:(iOS Collectionview报错)