【问题标题】:How to make last row to cover the remaning unoccupied space of tableview如何使最后一行覆盖tableview的剩余未占用空间
【发布时间】:2021-11-04 00:28:13
【问题描述】:

我有一个 tableview ,它有两行。

Tableview 的高度是 700。第一行高度是 150,第二行高度是 100,但我希望第二个单元格覆盖 tableview 中的其余空间。

我知道我可以使用下面的表格视图高度。但我愿意

override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat

【问题讨论】:

标签: ios swift uitableview uitableviewautomaticdimension


【解决方案1】:

很简单,替换掉这个方法

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    
    let tblHeight = infoTable.bounds.size.height
    return indexPath.row == 0 ? 150 : tblHeight - 150
    
}

只需将 infoTable 更改为您的表名即可。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-22
    • 1970-01-01
    • 2019-06-19
    • 2013-02-22
    • 2021-11-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多