【发布时间】:2018-08-07 10:15:58
【问题描述】:
我的tableview单元格的高度是自动计算的
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = UITableViewAutomaticDimension
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
{
return UITableViewAutomaticDimension
}
它在除 iPhone 5 之外的所有设备上都运行良好。在实际设备和模拟器中进行了尝试,结果相同:
任何想法为什么会发生? iOS 10.3.1
【问题讨论】:
-
检查你的约束。
-
试试 tableView.estimatedRowHeight = 10
-
我同意@MaheshDangar
-
@TmGoyani >它在除 iPhone 5 之外的所有设备上都运行良好。限制是什么原因?
-
@Edward 如果您想在所有设备中实现动态高度,那么您必须设置适当的约束并在 heightForRow 中返回“UITableViewAutomaticDimension”。
标签: ios swift uitableview