iOS Tips: Dynamic UITextView

A UITextView does not automatically resize in a UIView when you use AutoLayout alone; code is required—specifically, code similar to this:

CGSize size = self.textView.contentSize;
self.textViewHeightConstraint.constant = size.height;
UITableView *table = self.someTable;
for (SomeCell *cell in table.visibleCells) {
float height = cell.textView.contentSize.height;
cell.textHeightConstraint.constant = height;
[cell.textView sizeToFit];
}

Designer, iOS/macOS Developer; rider of motorcycles

Designer, iOS/macOS Developer; rider of motorcycles