我使用 tableview
配置了一个带有动态高度单元的 AutoLayout
,如下所示(我确定我的约束是正确的(从上到下))。我的 tableview
的内容设置为 Rx Binding
。
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
我尝试放置一个与所需高度行相对应的静态估计高度。
我的 tableview
被插入到 UIView
中,所有约束都为 0 (top, bottom, leading, trailing
),我需要更改大小以匹配 tableview 的大小。
我还尝试在 UIView
和 viewDidLayoutSubviews
中设置我的 viewWillAppear
的高度约束,但它不起作用
但是,当我到达屏幕时,包含 mytableView
的 UIView 没有正确的高度,因为该行小于它的内容。
我确切地说我尝试调用方法 layoutIfNeeded
并且它不起作用。我注意到,如果我再次调用 Rx binding
的 tableview
,大小是正确的。
你有什么想法吗?
提前致谢