UICollectionView's cellForItemAtIndexPath is not being called

后端 未结 30 2486
再見小時候
再見小時候 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:37

    Just resolved this issue, for a somewhat specific situation.

    In my case, I was manually initializing the UICollectionViewController in a parent ViewController, and then adding the UICollectionViewController's view as a subview.

    I resolved the issue by calling 'setNeedsLayout' and/or 'setNeedsDisplay' on the collectionView in the parent's viewDidAppear:

    - (void)viewDidAppear:(BOOL)animated {
       [super viewDidAppear:animated];
       [_collection.view setNeedsLayout];
       [_collection.view setNeedsDisplay];
    }
    

提交回复
热议问题