tableViewCell
contains viewController which height is calculated after tableView finish laying out views. So I need to trigger tableView
to request again height of rows by calling heightForRowAtIndexPath
method.
I have tried setNeedsLayout
, it does not work, system will not call heightForRowAtIndexPath
method.
reloadData
or reloadRowsAtIndexPaths
is not good choice, because it will reload all the cells, and all the viewControllers built into the cells, and again when the viewController will finished layout process and viewDidLayoutSubviews
is called, reloadData
will called again, so it is an infinite loop.
I was testing tableView.beginUpdates() tableView.endUpdates()
empty update operation. Sometimes it triggers heightForRowAtIndexPath
, sometimes not.