1

我的 tvOS 应用程序中有一个表格视图,其自定义行高为 250 像素(数量不多)。每个单元格的内容是一个文本视图,它(再次)具有 200 像素的恒定高度。当表格加载时,尺寸在初始渲染时看起来很好。

渲染时

但是当我真正关注单元格时,它默认为一些初始高度:

选择时

我试图让表格视图estimatedRowHeight加载:

tableView.estimatedRowHeight = 250
tableView.rowHeight = UITableViewAutomaticDimension

即使在 中实现行高方法UITableViewDelegate也无济于事:

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

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

我想我错过了一些非常简单的东西,但我想不出任何东西。提前致谢。

4

0 回答 0