I have a table view similar to the Compose screen in Mail, where one of the cells is used for text input. I'd like the cell to resize automatically by constraining the contentView
of the cell to its UITextView
subview using Auto Layout. The table view's rowHeight
and estimatedRowHeight
are set to UITableViewAutomaticDimension
. Additionally, the text view's scrollEnabled
property is set to false
so that it reports its intrinsicContentSize
.
However, the cell does not update its height as lines of text are entered by the user, even though the text view itself does update its intrinsic content size. As far as I know, the only way to request this manually is for the table view to call beginUpdates()
and endUpdates()
. The height of the cell is then correctly updated, but this also causes re-layout of the entire table view. Here's (someone else's) sample code demonstrating the problem.
How can I reflect changes in the cell's text view without laying out the entire table view?