【问题标题】:TableViewCell Auto height issueUITableViewCell 自动高度问题
【发布时间】:2017-04-22 05:52:11
【问题描述】:

我正在编写一个 iOS 应用程序。 用户输入电影搜索关键字,它会从 omdbapi.com 获取数据并在表格视图中显示电影。 问题是表格视图单元格没有正确显示。

项目网址: project on onedrive

我尝试使用所有自动布局方法,但都不起作用。

   override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return UITableViewAutomaticDimension;

    }

【问题讨论】:

标签: ios objective-c swift autolayout


【解决方案1】:

您还需要设置桌子高度的估算方法。所以将这些方法用于高度计算并检查您的单元格约束。

 func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
    return UITableViewAutomaticDimension
}

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    return UITableViewAutomaticDimension
    }

希望这会对你有所帮助。

【讨论】:

    猜你喜欢
    • 2014-12-15
    • 1970-01-01
    • 1970-01-01
    • 2016-06-19
    • 2016-12-30
    • 1970-01-01
    • 1970-01-01
    • 2014-01-03
    • 1970-01-01
    相关资源
    最近更新 更多