I'm creating headerview for collectionview cells using rxswift.While run the code it crashes iOS swift

 Problem:

I'm creating header view for collectionview cells using rxswift.While run the code it crashes.It show the below error.

2023-10-03 16:00:45.470422+0530 myapp[13244:2067307] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindSectionHeader with identifier HeaderCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'


But i had registered the cell before using as like below.

 self.mycollectionview.register(HeaderCell.nibforCellWithReuseIdentifierHeaderCell.identifier)



How to solve that?


Solution:


The problem was you are register the cell as forCellWithReuseIdentifier but you have to register the cell as like below.Then only it will works.


        mycollectionview.register(HeaderCell.nibforSupplementaryViewOfKindUICollectionView.elementKindSectionHeaderwithReuseIdentifierHeaderCell.identifier)




Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

store cgpoint in userdefaults iOS swift