【发布时间】:2017-03-09 10:38:11
【问题描述】:
我在容器视图中使用 uitableview,所以想根据内容大小高度设置我的容器高度。 因此,在重新加载 tableview 后,我正在更改容器的高度。但它似乎是根据估计的高度计算的。它没有给出实际高度。
这是我的约束布局。
instructiontableview.estimatedRowHeight = 55
instructiontableview.rowHeight = UITableViewAutomaticDimension
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// assigning multiline text to my label
cell.layoutIfNeeded()
cell.sizeToFit()
return cell
}
return UITableViewCell()
}
现在我正在从我的容器视图控制器重新加载并更改高度
【问题讨论】:
-
请同时添加相关代码和约束。
-
@agent_stack 请检查我更新的问题
-
您的标签内容正在发生变化,对于该内容,您必须更改单元格高度。我说的对吗??
标签: ios uitableview autolayout contentsize