Error could not dequeue a view of kind UICollectionElementKindCell

前端 未结 13 1358
耶瑟儿~
耶瑟儿~ 2020-12-16 09:34

Taking first plunge with collection views and am running into this error:

Terminating app due to uncaught exception \'NSInternalInconsistencyException

13条回答
  •  旧巷少年郎
    2020-12-16 10:13

    I know this is an old one, but I've experienced the same problem and wanted to share what fixed it for me.

    In my case, I've declared a global identifier

    let identifier = "CollectionViewCell"
    

    and had to use self right before using it:

    collectionView.dequeueReusableCellWithReuseIdentifier(self.identifier, forIndexPath: indexPath) as! CollectionViewCell
    

    Hope this helps someone :)

提交回复
热议问题