UITableView dynamic cell heights only correct after some scrolling

后端 未结 24 1278
误落风尘
误落风尘 2020-11-29 16:41

I have a UITableView with a custom UITableViewCell defined in a storyboard using auto layout. The cell has several multiline UILabels.

24条回答
  •  盖世英雄少女心
    2020-11-29 17:14

    This worked for me when other similar solutions did not:

    override func didMoveToSuperview() {
        super.didMoveToSuperview()
        layoutIfNeeded()
    }
    

    This seems like an actual bug since I am very familiar with AutoLayout and how to use UITableViewAutomaticDimension, however I still occasionally come across this issue. I'm glad I finally found something that works as a workaround.

提交回复
热议问题