More elegant could simply be implemented as suggested:
func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { return UITableViewAutomaticDimension }
Or in Objective C:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return UITableViewAutomaticDimension; }
But instead of defining a specific row, add restrictions on the contents of the static cells in the Storyboard to keep the row height constant. Thus, if you move lines or change content, you do not need to change any code.
Hippopatimus
source share