我的 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
}
我想我错过了一些非常简单的东西,但我想不出任何东西。提前致谢。