我的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 = UITableViewAutomaticDimension
仅适用于 iOS 11。
改用真实值:
if #available(iOS 11.0, *) {
tableView.estimatedRowHeight = UITableViewAutomaticDimension
} else {
tableView.estimatedRowHeight = 200
}
关于ios - 错误的 UITableViewAutomaticDimension 高度,仅适用于 iPhone 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51724304/