【问题标题】:UITableview dynamic height adjustment in UITableview cellUITableview单元格中的UITableview动态高度调整
【发布时间】:2019-08-15 09:49:25
【问题描述】:

我在UITableviewCell 中使用UITableview

我在UITableViewCell 中设置UITableview 的高度时遇到问题,但最初高度无法根据UITableview 的内容大小进行调整,但是当UITableview 重新加载或出队时,UITablevieWCell 中的tableview 高度会自动调整。

我想第一次调整这个高度。

下面是我在 tableview cellForRowAt 委托方法中审查的代码。

cell.tableviewShow.register(UINib(nibName: "Cell", bundle: nil), forCellReuseIdentifier: "Cell")
cell.tableviewShow.tag = indexPath.row

cell.tableviewShow.reloadData()
cell.layoutIfNeeded()
cell.heightOfTbleView.constant = cell.tableviewShow.contentSize.height
cell.tableviewShow.layoutIfNeeded()

【问题讨论】:

  • 你在TableViewCell里面有TableView吗?
  • @AmirKhan 是的。他想调整外部 tableview 单元格的大小以适应内部 tableview 的内容大小
  • @RajeshKumarR 完全正确

标签: ios swift uitableview storyboard ios-autolayout


【解决方案1】:

对于单元格使用中的动态高度:

tableView.rowHeight = UITableViewAutomaticDimension  
tableView.estimatedRowHeight = 60

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-21
    • 2020-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多