UITableView dynamic cell heights only correct after some scrolling

后端 未结 24 1231
误落风尘
误落风尘 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:12

    none of the above solutions worked for me, what worked is this recipe of a magic: call them in this order:

    tableView.reloadData()
    tableView.layoutIfNeeded() tableView.beginUpdates() tableView.endUpdates()

    my tableView data are populated from a web service, in the call back of the connection I write the above lines.

提交回复
热议问题