Rafael Ruiz Rafael Ruiz - 1 year ago 86
iOS Question

cellForItemAtIndexPath not called but numberOfItemsInSection does

This could be a duplicate post but I haven't found the solution in any of this:

enter image description here

I'm setting my


UINib *nib = [UINib nibWithNibName:@"CollectionViewCell"
bundle:[NSBundle mainBundle]];
[_collectionView registerNib: nib forCellWithReuseIdentifier:@"bCell"];

(I've tried to set delegate, without delegate, etcetera).

But then, only the

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
gets called while

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath

I've checked the numberOfItemsInSection I return, and it's always > 0 (it's exactly 17).

I've checked to call
[_collectionView reloadData];
and nothing happens either.

I've tried different things but I can't make it work.

Furthermore, my
should be here but it's not:

enter image description here

Does anyone have a clue?
Thank you.

Answer Source

Ok I think this could be useful for future problems with this...

It was because of constraints on the StoryBoard. I don't really understand why that happens, because I just had fixed an horizontal space. I removed the horizontal space as constraint for that View and everything works fine.

Well, let's life flow.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download