I went on and extended the autoresizing table cells to handle interface rotation and table editing as well. In both these cases, the width of the table cell content view changes, so the height of the text view needs to be recalculated. To achieve that, you need to wait to measure the new width of the text view until everything has settled down, but this turns out to be surprisingly difficult. The only functions I found that were called late enough in the view update cycle to give me the new definite text view width were didRotateFromInterfaceOrientation in the controller for rotations, and didTransitionToState in the table view cell for editing state changes.
In the controller:
override func didRotateFromInterfaceOrientation(
fromInterfaceOrientation: UIInterfaceOrientation) {
updateVisibleCells()
// after rotation, the cursor has a tendency to keep indicating editing
// even though the current view doesn’t respond to typing
// anymore. Ending editing cleans that up.
view.endEditing(true)
}
In the table view cell child class:
override func didTransitionToState(state: UITableViewCellStateMask) {
super.didTransitionToState(state)
updateTextViewSize()
}