【发布时间】:2021-01-21 06:49:51
【问题描述】:
我在表格视图单元格中有表格视图,需要根据表格视图内容设置表格视图高度,我尝试了下面的代码
extension tableViewCell: UITableViewDelegate{
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [self] in
lcOptionsTVHeight.constant = tableView.contentSize.height
}
}
}
但这在第一次加载时不起作用,而是在我上下滚动时更新,如何在第一次加载时正确加载?
【问题讨论】:
-
我从 anwser 得到了它 - stackoverflow.com/a/43520073/9166279
标签: ios swift uitableview