2
votes

I have a tableView with cells of different heights. I rely on iOS 8s autosizing feature to calculate the height. When the view loads everything looks great and according to plan. At some point a cell needs to be deleted. After the delete animation the rest of the cells would animated to a height of 44 pixels for unknown reason. All views in the cells are laid out using autolayout so I am cluless about the cause.

I can't try the following due to some constraints:

  • Reload the table view or
  • Use heightForRowAtIndexPath because a couple of the cells have dynamic height and aren't available when this delegate method is called.

The big question is Why? How do I counter this behavior?

The delete row is:

tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Fade)

The dynamic rows have multiline UILabels or UIViews. Autolayout is done via IB

1
Post the relevant code..snksnk
post the tableView's delegate methodsShoaib

1 Answers

3
votes

I was missing the following lines:

self.tableView.rowHeight = UITableViewAutomaticDimension
self.tableView.estimatedRowHeight = 44.0

The cells doesn't shrink anymore.