第一轮:
1、numberOfSectionsInTableView :假如section=2,此函数只执行一次,假如section=0,函数不执行,默认为1
2、heightForHeaderInSection ,执行两次,此函数执行次数为section数目
3、heightForFooterInSection ,函数属性同上,执行两次
4、numberOfRowsInSection ,此方法执行一次
5、heightForHeaderInSection ,此方法执行了两次,我其实有点困惑为什么这里还要调用这个方法
6、heightForFooterInSection ,此方法执行两次,
7、numberOfRowsInSection,执行一次
8、heightForRowAtIndexPath ,行高,先执行section=0,对应的row次数
第二轮:
1、numberOfSectionsInTableView ,一次
2、heightForHeaderInSection ,section次数
3、heightForFooterInSection ,section次数
4、numberOfRowsInSection ,一次
5、heightForHeaderInSection ,执行section次数
6、heightForFooterInSection,执行section次数
7、numberOfRowsInSection,执行一次
8、heightForRowAtIndexPath,行高,先执行一次
9、cellForRowAtIndexPath
10、willDisplayCell
然后8、9、10依次执行直到所有的cell被描画完毕
补充一下 : 设置tableview预估高度estimateHeight 启用预估高度之后:先调用estimatedHeightForRowAtIndexPath返回代理估计高度,然后再根据预估高度调用cellForRowAtIndexPath渲染cell内容,同时计算真实高度,最后再调用heightForRowAtIndexPath拿到计算的真实高度 显示
iOS11 默认开启可预估高度, iOS 11 之前开启预告也是 先9 后8 只是iOS11 之前预估默认关闭。关了预估高, 8 =》 9 self.tableView.estimatedRowHeight = 0; 关了预估高, iOS11 默认开启。 不管iOS几, 开启预估高 都是 9 -》8 关闭都是 8-》9