【发布时间】:2019-04-18 13:55:44
【问题描述】:
我只是在UItableviewcell 中创建UITableview(第二个UITableview)。我需要根据单元格的第二个 UITableview 数量增加 UItableviewcell 高度(第二个 UITableview's 单元格的高度不同)。
第一个表视图:
extension ViewController:UITableViewDelegate, UITableViewDataSource{
// no of row #1
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "OrderTimelineCell", for: indexPath) as! OrderTimelineCell
return cell;
}
}
第一个表格视图单元格:
override func awakeFromNib() {
tableView.layoutIfNeeded()
tableView.heightAnchor.constraint(equalToConstant: tableView.contentSize.height).isActive = true //always return 44*#cells
}
extension OrderTimelineCell:UITableViewDelegate, UITableViewDataSource{
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "TimelineTableViewCell", for: indexPath) as! TimelineTableViewCell
cell.label.text = array[indexpath.row] // text height different
return cell
}
}
我希望输出显示第二个UITableview 在第一个UITableview 单元格内的所有单元格。
但实际输出是单元格高度 == #no of cell * 44
【问题讨论】:
标签: ios swift uitableview