Dynamically increase height of UILabel & TableView Cell?

First of all you should not calculate height manually in auto layout environment. Just set both labels TopSpace and BottomSpace to cell’s contentView and make sure you set both labels NumberOfLines to 0 and LineBreakMode to WordWrap.

And the other constraint are as below,

ItemLabel:

enter image description here

SeparatorView:

enter image description here

DescriptionLabel:

enter image description here

And add the delegates for height as below,

#pragma mark - UITableView Delegates
-(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {

    return 44.0;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {

    return UITableViewAutomaticDimension;
}

You should get the output as below,

enter image description here

Hope this would help you.

Leave a Comment