Cellforitematindexpath Not Called But Numberofitemsinsection Does

cellForItemAtIndexPath not called but numberOfItemsInSection does

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.

UICollectionView's cellForItemAtIndexPath is not being called

For those who stumble here later.... the reason:

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

was not being called was because of the itemSize for the collectionViewFlowLayout's height was too big.

[self.myCollectionViewFlowLayout setItemSize:CGSizeMake(320, 548)];

If I change the height to 410, it will execute cellForItemAtIndexPath.

UICollectionView cellForItemAtIndexPath not called after numberOfItemsInSection returns nonzero item number

Turns out performBatchUpdates, according to UICollectionView Performing Updates using performBatchUpdates needs to be called after the change to my data source has been done. The issue was, though, that my method for deleting an item from my data source itself reloads the collection view, so there was an extra reload that did not need to happen, which was causing the issue, it seems. I initially had the call to my data source deletion method in the completion block of the performBatchUpdates, but moving that above and just reloading the entire collection view seems to have solved the issue. Seems like a weird race condition in my case where there are multiple reloads happening simultaneously and cellForItemAtIndexPath didn't like that.

cellForItemAtIndexPath is not called for collectionView

[myCollectionView setContentInset:UIEdgeInsetsMake(100, 0, 0, 0)];

Above line solves my problem.

UICollectionView cellForItemAtIndexPath method is not getting called

In your viewDidLoad method you probably want to add:

self.collectionView.delegate = self;
self.collectionView.dataSource = self;
[self.collectionView reloadData];

easy as that.

CollectionView method cellForItemAt indexPath: not being called (Swift)

Hint: CellforRow at:indexPath method won't be called if the size or position of the collectionView is changed before reload, make sure you're not doing that.



Related Topics



Leave a reply



Submit