美文网首页
iOS Collectionview报错

iOS Collectionview报错

作者: yezi1989 | 来源:发表于2018-07-31 16:58 被阅读29次

一直报错:

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报错

      本文链接:https://www.haomeiwen.com/subject/seyhvftx.html