I have a TableViewController
, which contains 2 ImageView
, some UILabel
.I set up the contains like this:
everything seems fine. and for the last UILabel
, I want to show all the content based on the length of the content, which means I need the TableViewCell
to adjust its height dynamically. I used this code to achieve this function:
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.estimatedRowHeight = 70
self.tableView.rowHeight = UITableViewAutomaticDimension
}
It works. However, when I scroll the TableView
, somethings strange happen, the screen flashed, and you can not scroll back to the top, something like this:
sorry I don't know how to show this error properly, it's flashing, and you cannot scroll the screen, you can only choose the back
button.
I guess this maybe something wrong with the AutoLayout
constrains, or the estimatedRowHeight
, here I just set it to 70
based on the tutorial I learnt, I don't know how to set this value properly.