我有一个 UITableView(表 1)。在 UITableView 单元中,我有另一个 UITableView(表 2)。
在行的Table 2
高度是。UITableViewAutomaticDimension
我的要求是 - 我希望它Table 2
不应该滚动并根据其中的行数取其全高。所以,根据 thisTable 2
的高度,我需要设置Table 1
的行高。
我正在使用 Table 2 的 contentSize.height,但它不起作用。我搜索了很多,但一无所获。
代码 :
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
{
let cell = tableView_First.dequeueReusableCell(withIdentifier: "SecondTableViewCell") as! SecondTableViewCell
return cell.second_TableView.contentSize.height
}
更新:
我已经调试了代码,发现表 2 的单元格的估计高度会影响表 1 的单元格的高度。即 - 如果表 2 的单元格的估计高度是 100,这些是 5 个单元格。然后这cell.second_TableView.contentSize.height
给了我 500。这是错误的。因为单元格的高度不同,分别为 10、20、30、40、10。
任何建议将不胜感激。
谢谢!