tableView创建方法调用的研究
当两个section的cell数量都为5的时候,方法的调用顺序:
-[ViewController numberOfSectionsInTableView:]
-[ViewController tableView:titleForHeaderInSection:]
-[ViewController tableView:titleForFooterInSection:]
-[ViewController tableView:numberOfRowsInSection:], section = 1
-[ViewController tableView:titleForHeaderInSection:]
-[ViewController tableView:titleForFooterInSection:]
-[ViewController tableView:numberOfRowsInSection:], section = 0
-[ViewController numberOfSectionsInTableView:]
-[ViewController tableView:titleForHeaderInSection:]
-[ViewController tableView:titleForFooterInSection:]
-[ViewController tableView:numberOfRowsInSection:], section = 1
-[ViewController tableView:titleForHeaderInSection:]
-[ViewController tableView:titleForFooterInSection:]
-[ViewController tableView:numberOfRowsInSection:], section = 0
-[ViewController numberOfSectionsInTableView:]
-[ViewController tableView:titleForHeaderInSection:]
-[ViewController tableView:titleForFooterInSection:]
-[ViewController tableView:numberOfRowsInSection:], section = 1
-[ViewController tableView:titleForHeaderInSection:]
-[ViewController tableView:titleForFooterInSection:]
-[ViewController tableView:numberOfRowsInSection:], section = 0
-[ViewController tableView:cellForRowAtIndexPath:], section = 0, row = 0
-[ViewController tableView:cellForRowAtIndexPath:], section = 0, row = 1
-[ViewController tableView:cellForRowAtIndexPath:], section = 0, row = 2
-[ViewController tableView:cellForRowAtIndexPath:], section = 0, row = 3
-[ViewController tableView:cellForRowAtIndexPath:], section = 0, row = 4
-[ViewController tableView:cellForRowAtIndexPath:], section = 1, row = 0
-[ViewController tableView:cellForRowAtIndexPath:], section = 1, row = 1
-[ViewController tableView:cellForRowAtIndexPath:], section = 1, row = 2
-[ViewController tableView:cellForRowAtIndexPath:], section = 1, row = 3
-[ViewController tableView:cellForRowAtIndexPath:], section = 1, row = 4
-[ViewController tableView:titleForHeaderInSection:]
-[ViewController tableView:titleForFooterInSection:]
-[ViewController tableView:titleForHeaderInSection:]
-[ViewController tableView:titleForFooterInSection:]
以下会调用三次
返回section的num
{
最后一个section
返回section的header
返回section的footer
返回section的行数
从第一个section开始
返回section的header
返回section的footer
返回section的行数
}
| section的数量 | 返回section的num{} | 返回section的num{}的调用顺序 | 最后调用header、footer的次数 |
| 1 | 三次 | 0 | 一组 |
| 2 | 三次 | 1、0 | 两组 |
| 3 | 三次 | 2、0、1 | 三组 |
| 4 | 三次 | 3、0、1、2 | 四组 |
| 5 | 三次 | 4、0、1、2、3 | 四组 |
| 6 | 三次 | 5、0、1、2、3、4 | 四组 |
问题一:为什么到section数量4以后,最后调用header、footer的次数的次数都为4
解决:在屏幕大小内绘制tableView,绘制多少内容,调用相应方法(如果一个section只露出一个header和几个cell,那么会先调用header,然后调用 tableView:cellForRowAtIndexPath:方法)
在设置的section内容之后,当前模拟器只能显示三个section(第三个section只有header露出来一点点,创建第一行cell和第二行cell,创建header和footer)
向下滑动,cell出现时,创建屏幕下下行cell(第一行cell出现,创建第三行cell)
section的倒数第二行cell出现时,不创建
section的最后一行cell的分界线出现时,创建下一个section的header
section最后一行cell出现时,先创建下一个section的第一行cell,然后创建section的footer
footer出现,不创建
下一个section的header出现时,创建下一个section的第二行cell
第一行cell出现时,创建第3行cell;
向上滑动,cell出现时,创建上一行cell(第二行cell出现,创建第一行cell)
第二行cell出现,创建第一行cell
第一行cell出现,不创建(plain模式,header还在头部)
header被拖动,footer将出现时,创建footer
footer出现,不创建
header将出现时,创建上一个section的最后一行cell,然后创建header
最后一行cell出现,创建倒数第二行;
问题二: 为什么“返回section的num{}”这一组方法每次都是调用三次?
tableView创建方法调用的研究的更多相关文章
- abap对象的创建和调用。方法调用
1: abap中创建类和创建对象,调用方法. *&---------------------------------------------------------------------* ...
- 03_java基础(四)之方法的创建与调用
import org.junit.Test; public class Main { public static void main(String[] args) { System.out.print ...
- 使用Swift开发iOS项目、UI创建、方法调用
//1.root控制器的创建 var rootCtrl =RootViewController() var root:UINavigationController =UIN ...
- java类.方法创建.继续调用
1.ctrl +n 创建类(首字母大写) 2.alt +s 选倒数第二个 创建方法(Superclass) 3.alt +s 选倒数第三个 创建带参数的方法(using fileds) 4.创建的vo ...
- spring声明式事务 同一类内方法调用事务失效
只要避开Spring目前的AOP实现上的限制,要么都声明要事务,要么分开成两个类,要么直接在方法里使用编程式事务 [问题] Spring的声明式事务,我想就不用多介绍了吧,一句话“自从用了Spring ...
- [转]Java远程方法调用
Java远程方法调用,即Java RMI(Java Remote Method Invocation)是Java编程语言里,一种用于实现远程过程调用的应用程序编程接口.它使客户机上运行的程序可以调用远 ...
- tableview 代理方法详解
typedef NS_ENUM(NSInteger, UITableViewCellAccessoryType) { UITableViewCellAccessoryNone, // 不显示任何图标 ...
- # 2017-2018-2 20155228 《信息安全系统设计原理》 使用VirtualStudio2008创建和调用静态库和使用VirtualC++6.0创建和调用动态库
使用virtual c++ 6.0创建和调用动态库 不得不说一下关于环境的问题 只要我打一个响指,一半的安装在win7上的VC6.0都会因为兼容性问题直接崩掉 懒得研究怎么解决兼容性的问题了,直接开一 ...
- spring声明式事务 同一类内方法调用事务失效(转)
原文 https://blog.csdn.net/jiesa/article/details/53438342 [问题] Spring的声明式事务,我想就不用多介绍了吧,一句话“自从用了Spring ...
随机推荐
- George and Cards
Codeforces Round #227 (Div. 2) E:http://codeforces.com/contest/387/problem/E 题意:给你一个n个数的序列,然后给你一个标准序 ...
- [Poetize I]黑魔法师之门
描述 Description applepi被囚禁的地点只有一扇门,当地 人称它为“黑魔法师之门”.这扇门上画着一张无向无权图,而打开这扇门的密码就是图中[每个点的度数大于零且都是偶数]的子图的个数对 ...
- POJ 2112 Optimal Milking(Floyd+多重匹配+二分枚举)
题意:有K台挤奶机,C头奶牛,每个挤奶机每天只能为M头奶牛服务,下面给的K+C的矩阵,是形容相互之间的距离,求出来走最远的那头奶牛要走多远 输入数据: 第一行三个数 K, C, M 接下来是 ...
- delphi NativeXml的中文支持 乱码
一般XML的编码格式设置成UTF8比较通用,下面演示使用UTF8编码方式存储和处理包含中文的XML字符串(文件).1.设置启用内置的widestring支持 NativeXml内部使用ANSI str ...
- Python根据上下限生成不重复随机数
Python 2.7.5 代码: # coding=gbk import random import sys min_num = input('输入下限:') max_num = input('输入上 ...
- C语言的强制类型转换
1.什么是强制类型转换:遇到一些类型不同的一些数据之间的表达运算 ,需要将较高的数据类型转换成较低类型时. 2.强制类型的形式: (强制转换的类型)(表达式): 2.强制类型的使用: float a, ...
- mac下的改装人生——制作mac os 启动盘
我即将开始对我的mac进行彻底的改造,现在还需要的是一个mac的启动盘或者启动光盘.由于没钱买mac的安装光盘或者安装盘,只能网上下了一个镜像自己做启动盘~ 需要:装有Mac Os的电脑,至少8g的u ...
- poj 1609 dp
题目链接:http://poj.org/problem?id=1609 #include <cstdio> #include <cstring> #include <io ...
- Solr开发参考文档(转)
Solr开发文档 Solr 是一种可供企业使用的.基于 Lucene 的搜索服务器,它支持层面搜索.命中醒目显示和多种输出格式.在这篇文章中,将介绍 Solr 并展示如何轻松地将其表现优异的全文本搜索 ...
- Python监控日志程序
一个简易的日志监控的脚本,功能如下:1.windows环境2.当匹配日志关键字时会发出声音,匹配的关键字不同,播放的声音不同3.能做到实时响应 注意:是在win环境下哦 直接上代码吧 1 2 3 4 ...