Dynamic text of variable length are being injected into tableview cell labels. In order for the tableview cells' heights to be dynamically sized, I have implemented in viewDidLoad()
:
self.tableView.estimatedRowHeight = 88.0
self.tableView.rowHeight = UITableViewAutomaticDimension
This works nicely for the cells that have yet to be scrolled to (as UITableViewAutomaticDimention
is called upon scrolling to the cell), but not for the cells that are initially rendered onscreen upon loading the table with data.
I have tried simply reloading the data (as suggested in many other resources):
self.tableView.reloadData()
in both viewDidAppear()
and viewWillAppear()
and it was to no avail. I am lost.. does anyone know how to have xcode render the dynamic height for the cells loaded initially on screen?
Please let me know, if there is a better alternate method.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…