我有一个UITableView(表1)。在UITableView Cell中我有另一个UITableView(表2)。TableView单元格动态高度
在Table 2
行的高度是UITableViewAutomaticDimension
。
我的要求是 - 我想这Table 2
不应滚动,并采取充分的高度,每个里面it.So的行数,按本Table 2
的高度,我需要设置Table 1
的行高。
我使用表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。
任何建议,将不胜感激。
谢谢!
感谢您的回答。但是这段代码给了我“Bad _Access”。我检查了错误https://stackoverflow.com/questions/35931478/why-tableview-cellforrowatindexpathindexpath-give-me-a-bad-access-error。你能建议现在做什么? – Amanpreet