通常当我想设置行高时再设置
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 300
}
estimatedHeightForRowAt
有什么好处我应该什么时候使用它。
更新!如果我想设置 estimatedHeightForRowAt:
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return // what should i put here
}
更新:
如果我按照自己的意愿提供 estimatedHeightForRowAt,是否会影响 tableview 滚动? .例如我给出 estimatedHeightForRowAt 500
最佳答案
如 iOS documentation 中所述:
If the table contains variable height rows, it might be expensive to calculate all their heights and so lead to a longer load time. Using estimation allows you to defer some of the cost of geometry calculation from load time to scrolling time.
关于ios - heightForRowAt 与 estimatedHeightForRowAt 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45267576/