I have a bit of a tricky set up in my storyboard, I have a UIViewController that holds a UITableViewController. Within the UITableViewController I have several prototypecell
Swift 4.2 and 5. As mention above you can set UITableView object property or
tblView.rowHeight = UITableView.automaticDimension
tblView.estimatedRowHeight = 300
you can also define the same by implementing UITableViewDelegate methods
extension ViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return 300
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
}