gpt4 book ai didi

ios - 我应该在 cellForItemAtIndexPath 还是 willDisplayCell 上设置单元格?

转载 作者:行者123 更新时间:2023-12-01 20:08:13 26 4
gpt4 key购买 nike

this page谈到平滑表格 View 滚动的技巧,说表格 View 单元格不应该在 tableView:cellForRowAtIndexPath: 上绘制而是在 tableView:willDisplayCell:forRowAtIndexPath: 上.

我已经尝试过这种方法,并且在我的初始测试中没有发现任何差异。这有什么真相吗?

我真的应该使用tableView:willDisplayCell:forRowAtIndexPath:创建单元格、设置缩略图、文本等,而不是 tableView:cellForRowAtIndexPath: ?

最佳答案

是的,两个 执行 相同功能 但是 使用 cellForRowAtIndexPath对于 TableView ,数据源 必须实现为 cellForRowAtIndexPath 工作速度快并且您必须快速返回重复使用的单元格标识符。这是tableview的数据源方法
tableView:willDisplayCell:forRowAtIndexPath是委托(delegate)而不是数据源的方法。该方法在加载 UITableView 中的单元格之前被调用。界限。

关于ios - 我应该在 cellForItemAtIndexPath 还是 willDisplayCell 上设置单元格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38254315/

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