• 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{}”这一组方法每次都是调用三次?

  • 相关阅读:
    springboot+thymeleaf+pageHelper带条件分页查询
    用JavaScript写一个简单的计算器
    运用java反射机制获取实体方法报错,java.lang.NoSuchMethodException: int.<init>(java.lang.String)
    前端页面优化
    MySQL常用dos命令
    python 学习笔记(四) 统计序列中元素出现的频度(即次数)
    python 学习笔记(二):为元组的每个元素命名,提高程序的可读性
    python 学习笔记(一):在列表、字典、集合中根据条件筛选数据
    Python 字符串前面加u,r,b,f的含义
    python3中文件操作及编码
  • 原文地址:https://www.cnblogs.com/LiuLady12138/p/4674423.html
Copyright © 2020-2023  润新知