Why on Xcode 11, UICollectionViewCell changes size as soon as you scroll (I already set size in sizeForItem AtIndexPath:)?

前端 未结 4 1764
抹茶落季
抹茶落季 2020-12-04 19:51

I have collectionview inside tableview cell and I use nib for my collection view cell (in which I use autolayout for my imageview and labels and it is on Freeform

4条回答
  •  心在旅途
    2020-12-04 20:10

    As Anh Tuan said in another answer here, you just need to change the Estimate Size to none in the Size Inspector of the Collection View from the Storyboard.

    But if you wanna do this programmatically, you can try this code:

        let layout = myCollectionViewReferenceHere.collectionViewLayout as! UICollectionViewFlowLayout
        layout.estimatedItemSize = .zero
    

提交回复
热议问题