美文网首页
Swift CollectionReusableView注册失败

Swift CollectionReusableView注册失败

作者: Abel0101 | 来源:发表于2018-06-26 13:39 被阅读52次

1.程序奔溃并且报错 reason: 'could not dequeue a view of kind: UICollectionElementKindSectionHeader with identifier GTNotificationReusableView - must register a nib or a class for the identifier or connect a prototype cell in a storyboard' 时,应该查看是否已经注册以及注册方法有没有出错,collectionView.register(UINib(nibName:headerlName, bundle:nil), forSupplementaryViewOfKind:UICollectionElementKindSectionHeader, withReuseIdentifier:headerlName)

2.程序奔溃并且报错 Could not cast value of type 'UICollectionReusableView' (0x1137cafe0) to xxx 

这个是因为类型不同强转导致的,这种情况修改的方法是将CollectionReusableView的类型改成我们自定义的类名。

修改前 修改后

相关文章

网友评论

      本文标题:Swift CollectionReusableView注册失败

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