Mark Newton
Mark Newton

Reputation: 75

Subclass of UICollectionViewCell Not Displaying

I have a UICollectionView that is displayed by clicking a table cell within a navigation controller. So the UICollectionView is the second screen in the navigation controller's stack.

Cells showed up fine in the collection view when I registered a nib and created the cell via the UICollectionViewCell class. But once I try to create a subclass for the cell, the collection view just shows up as a black screen. My project can be found here. Link to Project in Dropbox

To subclass the UICollectionViewCell, I did the following:

enter image description here

From what I've read, that should do it! But the collection view is showing up blank, can anyone help??

Upvotes: 5

Views: 2550

Answers (1)

Anil Varghese
Anil Varghese

Reputation: 42977

I checked your code. You have done perfectly. Collection view with cells is showing correctly, but you cannot see that since you are not setting any of the property of the cell. Just check by setting background color of the cell in cellForItem

  cell.backgroundColor = [UIColor redColor];

If you are done everything in nib then you need to register nib instead of class. use registerNib instead of registerClass. If you are registering class you have to do everything programmatically.

Upvotes: 7

Related Questions