Reputation: 4844
I'm just starting to use the UICollectionView so bear with me!
How do I load a nib into the cell?
It seems I have to register the nib and class to be used, but this does not work.
Code:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
[collectionView registerClass:[CluelessSymbolCell class] forCellWithReuseIdentifier:@"Symbol cell"];
[collectionView registerNib:[UINib nibWithNibName:@"CluelessSymbolCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"Symbol cell"];
CluelessSymbolCell *cell = (CluelessSymbolCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"Symbol cell" forIndexPath:indexPath];
CluelessClue *clue = [clueManager clueForIndexPath:indexPath];
[cell.backgroundImageView setImage:[UIImage imageNamed:[clue.imageNames objectAtIndex:0]]];
return cell;
}
Upvotes: 3
Views: 3427
Reputation: 4844
It turns out my nib file had the default view controller in it (which was hidden) as well as my custom cell - doh!
Upvotes: 1