zoukankan      html  css  js  c++  java
  • 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{}”这一组方法每次都是调用三次?

  • 相关阅读:
    cocos2dx 3.x 集成protobuf
    Lua面向对象之三:其它一些尝试
    Lua面向对象之二:类继承
    Lua面向对象之一:简单例子
    cocos2dx lua 绑定之二:手动绑定自定义类中的函数
    向量点积、叉积的意义
    cocos2dx lua 绑定之一:自动绑定自定义类中的函数
    Lua和C++交互 学习记录之九:在Lua中以面向对象的方式使用C++注册的类
    Lua和C++交互 学习记录之八:C++类注册为Lua模块
    Lua和C++交互 学习记录之七:C++全局函数注册为Lua模块
  • 原文地址:https://www.cnblogs.com/LiuLady12138/p/4674423.html
Copyright © 2011-2022 走看看