Search code examples
swiftuitableviewtableviewheightcell

Swift: Dynamic Cell in table view


I'm trying to make the height of table view cell = the content of the cell.

I implemented these 2 lines in the viewDidLoad():

tableView.estimatedRowHeight = 200.0
tableView.rowHeight = UITableViewAutomaticDimension

and here are the constraints in the cell

Still, the cell is changing its height!


Solution

  • TextView will not expand to fit the entire text by default because it has scrolling capabilities, for what you want you should disable scrolling in the textView.

    Select the textView and in the Attributes Inspector tab scroll down and uncheck the "Scrolling Enabled"