Automatic dimension UITextView inside UITableViewCell

Tram Ho

Hello everyone, this article I write about how dynamic UITextView inside UITableViewCell.

First, I created the viewcontroller to create only one normal table view, the height setting of the cell is UITableViewAutomaticDimension to help UITableViewCell automatically scale according to the content inside:

Next, I will create a cell named “AddCell”, after creating, I drag a UITextView inside and auto layout like this:

Inside the AddCell.swift file, I implement UITextViewDelegate and create AddCellDelegate as shown below:

Finally, in the ViewController file, I implement AddCellDelegate:

I set the color of the table view is gray, the text view is while to see more clearly, the results I get are as follows:

Thank you for reading my article 😀

Share the news now

Source : Viblo