Search code examples
iosios8autolayoutios9nslayoutconstraint

Cell heights "wrong on load" when changing heights at runtime


My current project nicely shows changing the height of cells, when you select a cell1. Everything is perfect.

But, in my current code, when you first launch the app, the heights are wrong.

As soon as you select/unselect some rows or perhaps scroll, everything is perfect.

enter image description here

I can't find the problem. Already tried tableView.reloadData() in viewDidAppear, doesn't help. Any ideas? What could cause this?


1 By the way if you're just starting with autolayout the example data is from the popular demo of how to make a (static) variable height cell at: appcoda.


Solution

  • Use

    reloadSections(NSIndexSet(index: 0), withRowAnimation: .Automatic)

    instead of reloadData()