ios - UITableview 问题的动态高度

标签 ios swift uitableview

我已经设置了

self.tableView.estimatedRowHeight = 88.0
self.tableView.rowHeight = UITableViewAutomaticDimension

此外,我已将 UILabel 的 numberOfLines 归零。 我没有在 IB 中给出任何固定的高度/宽度限制。 我的 UITableviewCell 高度仍然没有相应地扩展。

请建议我该怎么做。

最佳答案

试试这个:

func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
    return UITableViewAutomaticDimension
}

编辑

func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
    return UITableViewAutomaticDimension
}

定义以上两种方法。它解决了问题。

关于ios - UITableview 问题的动态高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37253575/

相关文章:

ios - 为 iOS 应用程序创建介绍屏幕

ios - 应用程序 UI 由于网络、iOS 而挂起

ios - iOS-更新APNS发行证书

ios - 去除重力对 IOS iphone 加速度计的影响

ios - 当我按下 Swift 中的两个按钮时,如何显示第三个按钮?

ios - 暂停后恢复计时器?

swift - 如何在 swift 中找到两个 unix 时间之间的分钟差异?

ios - 调整 UITableViewCell 框架问题的大小

ios - UITableViewCell 在某些 indexPath.rows 的 Swift 2 彩色背景

ios - 使用带有 Firebase 后端的 UITableViewController 显示排行榜 (Swift 4.1)