Our UITableView exists on a ViewController (and not a TableViewController). We populate it at run time with two rows. When we set a height constraint the table appears fin
We don't have automatic dimension for UITableView, they only affect the UITableViewCell height. If you want to set the table view height dynamically, I think the best way is to set the table view height constraint equal to its content size after the table view done loading. I mean something like,
tableViewHeightConstraint.constant = tableView.contentSize.height
You can change tableView frame in multiple ways, with animations etc.
tableView.frame = CGRect(x: leftTableBorder, y: topTableBorder, width: tableWidth, height: tableHeight)
Or you can change tableView related constraints and then update constraints with layoutIfNeeded, also animated if you wish.
For example if you have a height constraint property:
tableViewHeightConstraint.constant = desiredHeight
layoutIfNeeded()
In any case, constraints are needed, so autolayout knows how to render the table.