UICollectionView's cellForItemAtIndexPath is not being called

后端 未结 30 2251
再見小時候
再見小時候 2020-12-07 11:11

Only my second time using UICollectionView\'s and perhaps I have bitten off more than I can chew but nevertheless:

I am implementing a UICollectionView (myCollection

相关标签:
30条回答
  • 2020-12-07 11:43

    In my case, changing UINavigationBar's translucent to NO solved the problem.

    0 讨论(0)
  • 2020-12-07 11:44

    It was happening for me when item height == 0 by fixing that cellForItem method was called.

    0 讨论(0)
  • 2020-12-07 11:44

    Ten minutes ago I also encountered this problem, I made a silly mistake.

    My intention is to use UICollectionViewFlowLayout,

    But because of mistakes, I used UICollectionViewLayout.

    0 讨论(0)
  • 2020-12-07 11:45

    Make sure -(NSInteger) collectionView:numberOfItemsInSection: is returning a positive (read, greater than zero) value. It may be a matter of placing [self.collectionView reloadData]; in the completion handler.

    0 讨论(0)
  • 2020-12-07 11:48

    I was using autolayout, and in my case height constraint was missing

    0 讨论(0)
  • 2020-12-07 11:48

    For me, I update the height of self.view (the collectionView's superview) via autolayout, and MUST call layoutIfNeeded after that.

    [self.view mas_updateConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@(height));
    }];
    [self.view layoutIfNeeded];
    
    0 讨论(0)
提交回复
热议问题