4

在此处输入图像描述

我在 UITableViewCell 中有一个 UIView ,当用户点击“更少/更多”按钮时需要改变它的高度

我的代码是

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

1 回答 1

5

将项目高度约束挂钩为 IBOutlet 并像这样在cellForRow中更改它

 cell.viewHeightCon.constant = // value

在返回单元格之前添加

 cell.layoutIfNeeded()
于 2018-01-23T12:23:47.310 回答