I am trying to use the new auto size for my tableview. Im doing this:
tableView.rowHeight = UITableViewAutomaticDimension
I have a multi-line uilabel in my UITableViewCell with some restrictions that work great; row height is dynamic when I enter the table view in both landscape and portrait! Fine!
... but when I rotate the device, the rows get the base height (i.e. 44).
I added this line:
override func willAnimateRotationToInterfaceOrientation(toInterfaceOrientation: UIInterfaceOrientation, duration: NSTimeInterval)
{
self.tableView.reloadData()
}
And the problem disappears. But is it really necessary? Should there be a better way to fix this?
Edit:
I just found out that the same problem occurs when I delete a row as a table as follows:
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
Am I missing something? Why does it work out of the box?
Change again:
Now I do like this:
self.tableView.estimatedRowHeight = 44
tableView.rowHeight = UITableViewAutomaticDimension
, API:
self.tableView.reloadData()
self.tableView.beginUpdates()
self.tableView.endUpdates()
, , , , ! / . ( .)
. , .