I'm having an issue combining Autolayout with dynamic cell resizing and having cells grow when selected.
My current implementation has the cell set to height 70 in unselected state. It is laid out with AutoLayout and has extra information hidden, from pixel 71 to 220:
Normal cell label
---------------- 70px
UILabel
UITextView
UIButton
---------------- 220px
The expanded info in this case is positioned with AutoLayout to be below normal cell label.
The UITextView in the expanded info should grow to fit the content, increasing the size of the cell beyond 220px.
I calculate this in heightForRow, by dequeueing a cell, configuring it and asking for its height using systemLayoutSizeFittingSize:.
Unfortunately, this fails to give me the correct size about 75% of the time. The exception is when:
1. I load the normal cell and tap to expand.
2. I then scroll down, and scroll back up to the expanded cell.
3. The expanded cell is now the correct height after recycling (still expanded)
I've heard systemLayoutSizeFittingSize: needs top to bottom AutoLayout constraints, but I can't enforce a bottom constraint as this would mean these elements would be visible in the unexpanded state.
The problem appears to be stemming from AutoLayout, and the fact it doesn't produce the correct size most of the time, even with setNeedsLayout and layoutIfNeeded.
For the most part, I've been using the following tutorial: http://www.raywenderlich.com/73602/dynamic-table-view-cell-height-auto-layout