collectionViewContentSize in iOS 10 using self-sizing cells

后端 未结 4 1271
你的背包
你的背包 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

    This is some strange bug in iOS10 with iPhone Plus devices only. I've faced the same issue, my solution was to call layoutIfNeeded like this:

    func numberOfSections(in collectionView: UICollectionView) -> Int {
        collectionView.layoutIfNeeded() // Patch: only to solve UIKit crash on Plus models
        return 1
    }
    

    Doing the same thing in different UICollectionViewDataSources methods will work as well

提交回复
热议问题