UITableView方法的执行顺序

1.它会调用代理方法确定有几行

[TableViewController numberOfSectionsInTableView:]

2.确定每行的表头高和表尾高(如果设定了HeardView和FooterView)

[TableViewController tableView:heightForHeaderInSection:]
[TableViewController tableView:heightForFooterInSection:]

3.确定每行有多少的cell

[TableViewController tableView:numberOfRowsInSection:]

4.然后确定每行cell的高度

[TableViewController tableView:heightForRowAtIndexPath:]
-------------如果设置多行及重复执行以上方法-----------

5.以上信息确定完毕后及调用代理方法去获取cell

[TableViewController tableView:cellForRowAtIndexPath:]

6.返回cell的高度

[TableViewController tableView:heightForRowAtIndexPath:]

7.cell将要显示到屏幕上

[TableViewController tableView:willDisplayCell:forRowAtIndexPath:]

8.cell超出屏幕进行服用时及会调用两次

[TableViewController tableView:heightForRowAtIndexPath:]

然后在进行调用 5 . 6. 7 方法

-[TableController tableView:heightForRowAtIndexPath:]  0
-[TableController tableView:heightForRowAtIndexPath:]  0
-[TableController tableView:cellForRowAtIndexPath:]  0
-[TableController tableView:heightForRowAtIndexPath:]  0
-[TableController tableView:heightForRowAtIndexPath:]  1
-[TableController tableView:heightForRowAtIndexPath:]  1
-[TableController tableView:cellForRowAtIndexPath:]  1
-[TableController tableView:heightForRowAtIndexPath:]  1
-[TableController tableView:heightForRowAtIndexPath:]  2
-[TableController tableView:heightForRowAtIndexPath:]  2
-[TableController tableView:cellForRowAtIndexPath:]  2
-[TableController tableView:heightForRowAtIndexPath:]  2
-[TableController tableView:heightForRowAtIndexPath:]  3
-[TableController tableView:heightForRowAtIndexPath:]  3
-[TableController tableView:cellForRowAtIndexPath:]  3
-[TableController tableView:heightForRowAtIndexPath:]  3
-[TableController tableView:heightForRowAtIndexPath:]  4
-[TableController tableView:heightForRowAtIndexPath:]  4
-[TableController tableView:cellForRowAtIndexPath:]  4
-[TableController tableView:heightForRowAtIndexPath:]  4
-[TableController tableView:heightForRowAtIndexPath:]  5
-[TableController tableView:heightForRowAtIndexPath:]  5
-[TableController tableView:cellForRowAtIndexPath:]  5
-[TableController tableView:heightForRowAtIndexPath:]  5
-[TableController tableView:heightForRowAtIndexPath:]  6
-[TableController tableView:heightForRowAtIndexPath:]  6
-[TableController tableView:cellForRowAtIndexPath:]  6

问题?调用cell高度的时候会设置 cell的高度吗?
-[TableController tableView:heightForRowAtIndexPath:] 19
-[TableController tableView:heightForRowAtIndexPath:] 19
-- setFrame ---
-[TableController tableView:cellForRowAtIndexPath:] 19
-[TableController tableView:heightForRowAtIndexPath:] 19
-- setFrame ---

调用两次 heightForRowAtIndexPath 在这只cell 的高度 再次创建 cellForRowAtIndexPath

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容