Collection Reusable Views, including Collection View Cells (which is a subclass), have a field in Interface Builder called "Identifier" with prompt "Reuse Identifier".
However, you normally use it by registering it with the UICollectionView
using the –registerNib:forCellWithReuseIdentifier:
and –registerNib:forSupplementaryViewOfKind:withReuseIdentifier:
methods, where you also specify a reuse identifier.
So then what's the point of setting one in Interface Builder? It seems to make no difference whether you set it there or not.
If you implicitly load a collection view from a storyboard you only have to do
UICollectionView *cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:@"CollectionViewCell" forIndexPath:indexPath];
to get the cell. You don't need to call registerNib:
. This only works if you set a reuse identifier.
For NibCell (UICollectionView in a Nib) you must use registerNib:, that's only way. If you give your Cell in Nib a reuse identifier, this identifier must same in register so better leave it blank.
-Cell by Code: registerClass
-Cell in Nib(Xib) registerNib
-Cell in StoryBoard: don't register
One more answer of mine here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With