gpt4 book ai didi

ios - heightForRowAt 与 estimatedHeightForRowAt 有什么区别?

转载 作者:搜寻专家 更新时间:2023-10-31 22:05:07 24 4
gpt4 key购买 nike

通常当我想设置行高时再设置

 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com