collectionViewContentSize in iOS 10 using self-sizing cells

后端 未结 4 1273
你的背包
你的背包 2021-02-08 13:05

Prior to iOS 10, I had a self-sizing table view that solely consisted of a UICollectionView with self-sizing cells using a standard UICollectionViewFlowLayout. The collection v

4条回答
  •  深忆病人
    2021-02-08 13:27

    In my case, calling invalidateLayout before layout is a workaround for this issue.

    In a UIViewController subclass:

    override func viewWillLayoutSubviews() {
        super.viewWillLayoutSubviews()
        collectionView.collectionViewLayout.invalidateLayout()
    }
    

    or in a UIView subclass:

    override func layoutSubviews() {
        super.layoutSubviews()
        collectionView.collectionViewLayout.invalidateLayout()
    }
    

提交回复
热议问题