We can use the "UITableViewAutomaticDimension" in iOS 8 to explicitly use dynamic size using the following two properties: -
tableView.estimatedRowHeight = 60.0
tableView.rowHeight = UITableViewAutomaticDimension
Then add the following code to the cellForRowAtIndexPath method in front of the return cell.
cell.setNeedsUpdateConstraints()
cell.updateConstraintsIfNeeded()
iOS 9 tableView: -
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
}
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}