【问题标题】:How to set Dynamically UITableView height in Swift?如何在 Swift 中动态设置 UITableView 高度?
【发布时间】:2018-08-09 13:10:24
【问题描述】:

如何像在 android 中一样动态设置 Tableview 高度。我尝试使用以下代码,但它不起作用。

 tblHeightConstraint.constant = downSelectionTbl.contentSize.height

请参阅下面的链接,即使它没有解决我的问题,我也厌倦了投票答案。

iOS: Dynamically set UITableView height in Swift

【问题讨论】:

    标签: ios swift uitableview


    【解决方案1】:

    这样做,

    func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
        tblHeightConstraint.constant = downSelectionTbl.contentSize.height
    }
    

    【讨论】:

    • @ram 替代解决方案检查这个答案:stackoverflow.com/questions/2595118/…
    • func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell 这个函数就像一个魅力.. Thq @venkat
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-17
    • 1970-01-01
    • 2018-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多