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 fine. When we don't set the height constraint the table completely does not appear. How can you set the UITableView to dynamically set its height?
I've seen threads about dynamically setting the row height (which does work well) but not about the actual table height. There are a few threads on this specific point but none seem to work for me.
Update on solution: As Robotic Cat suggested we set up a height constraint on the UITableView
in the Storyboard (we had that already) and then did Ctrl drag to create an IBOutlet
in our controller. From there we executed the following code in viewWillAppear
per Vignesh's answer:
tableViewHeightConstraint.constant = tableView.contentSize.height
Note before executing the above code we are calling reloadData()
in the same method to populate our table.