问题
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;
}
回答1:
Hook items height constraint as IBOutlet and change it in cellForRow like this
cell.viewHeightCon.constant = // value
and before return cell add
cell.layoutIfNeeded()
来源:https://stackoverflow.com/questions/48401654/how-to-change-height-constraint-of-uiview-in-uitableviewcell-when-using-uitablev