iOS 8 introduced a way for tableViews to automatically adjust their cell\'s height based on their content (via AutoLayout).
// in viewDidLoad:
tableView.rowHeigh
The tableView
has to be informed that the textView
has changed. Other posts usually answer a "static" textView
problem. However, if you are typing inside a table, the cell needs to grow as the textView
grows as you type. The textView
grows by disabling scrolling. The cell grows by setting the textView
's top and bottom constraints to those of the contentView
of the cell. This will work once, once the table loads. However to tell the tableView
to grow in real time, you have to do in the textView
's didChange
delegate call
func textViewChanged(onCell cell: YourCustomCell) {
UIView.setAnimationsEnabled(false)
tableView.beginUpdates()
tableView.endUpdates()
UIView.setAnimationsEnabled(true)
}
This will work as you expect. The cell will grow as you type and there won't be a "bouncing".