How can a get the auto layout size of the UICollectionViewCells in iOS 8? (systemLayoutSizeFittingSize returns size with zero height in iOS 8)

后端 未结 8 521
心在旅途
心在旅途 2021-01-30 14:21

Since iOS 8 [UIColletionViewCell systemLayoutSizeFittingSize:UILayoutFittingCompressedSize] returns a size with height of 0.

Here\'s what the code

8条回答
  •  失恋的感觉
    2021-01-30 15:03

    What you need to do is wrap all of your content in a container view, then call:

    return [sampleCell.containerView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
    

    Your cell should look like this: cell -> containerView -> sub views

    This works on both ios7 & ios8.

    Supposedly on ios8, all you have to do is set the estimateSize & cell will automatically auto size on its own. Apparently that's not working as of beta 6.

提交回复
热议问题