滚动时不调用estimatedHeightForRowAt [英] estimatedHeightForRowAt is not called on scroll
问题描述
为什么我们在滚动UITableView
时没有调用UITableViewDelegate
协议的estimatedHeightForRowAt
方法?
Why method estimatedHeightForRowAt
of the UITableViewDelegate
protocol is not called when we are scrolling UITableView
?
方法 estimatedHeightForRowAt
仅在我们初始化 UITableView 时调用.
Method estimatedHeightForRowAt
is called only when we initialize UITableView.
推荐答案
只有在我们初始化 UITableView 时才会调用方法estimatedHeightForRowAt.
Method estimatedHeightForRowAt is called only when we initialize UITableView.
正确.前面的所有行都会调用它,因此我们可以估计表格内容的整个高度.这正是它的用途.
Correct. It is called for all rows up front, so we can estimate the whole height of the table content. That is exactly what it is for.
当您滚动并且新行即将出现时,这些现在是包含真实单元格的真实行,因此现在您必须提供真实高度!
When you scroll and the new rows are about to appear, those are now real rows with real cells in them, so now you must give the real heights!
这篇关于滚动时不调用estimatedHeightForRowAt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!