SThakur
SThakur

Reputation: 282

How to change height Constraint of UIView in UitableviewCell when using UITableViewAutomaticDimension

enter image description here

I have a UIView in the UITableViewCell , which needs to change its height when user taps on "less/more" button

My code is

 - (CGFloat)tableView:(UITableView *)tableView       estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return UITableViewAutomaticDimension;
}

Upvotes: 5

Views: 1480

Answers (1)

Shehata Gamal
Shehata Gamal

Reputation: 100503

Hook items height constraint as IBOutlet and change it in cellForRow like this

 cell.viewHeightCon.constant = // value

and before return cell add

 cell.layoutIfNeeded()

Upvotes: 6

Related Questions