一、前言

  iOS中UITableView是最常用的一个控件。看了一下UITableView的代理:UITableViewDelegate 和 UITableViewDataSource。其中UITableViewDelegate的方法有38个,UITableViewDataSource的方法有11个。下面来简单介绍一下。(方法代码有点多)

二、UITableViewDelegate方法

  UITableViewDelegate的38个方法所有的都是可选的。也就是你可以实现,也可以不实现。这里就不一一介绍了,简单的看一下这个图:

三、UITableViewDataSource方法

UITableViewDataSource的11个方法中有2个是必须实现的:

  1. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
  2.  
  3. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;

简单看一下UITableViewDataSource代理方法:

五、方法执行顺序问题

  这里面没有将所有的方法都考虑进去,这里只是对UITableView实例从创建到完全显示进行测试,而且都是常用的方法,实现其他方法其输出内容可能不一样,但整体结构不变。其中包括UITableViewDelegate的:

  1. - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
  2. NSLog(@"%@",NSStringFromSelector(_cmd));
  3. }
  4. - (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section {
  5. NSLog(@"%@",NSStringFromSelector(_cmd));
  6. }
  7. - (void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section {
  8. NSLog(@"%@",NSStringFromSelector(_cmd));
  9. }
  10. - (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath*)indexPath {
  11. NSLog(@"%@",NSStringFromSelector(_cmd));
  12. }
  13. - (void)tableView:(UITableView *)tableView didEndDisplayingHeaderView:(UIView *)view forSection:(NSInteger)section {
  14. NSLog(@"%@",NSStringFromSelector(_cmd));
  15. }
  16. - (void)tableView:(UITableView *)tableView didEndDisplayingFooterView:(UIView *)view forSection:(NSInteger)section {
  17. NSLog(@"%@",NSStringFromSelector(_cmd));
  18. }
  19.  
  20. // Variable height support
  21.  
  22. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  23. NSLog(@"%@",NSStringFromSelector(_cmd));
  24. return ;
  25. }
  26. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  27. NSLog(@"%@",NSStringFromSelector(_cmd));
  28. return ;
  29. }
  30. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
  31. NSLog(@"%@",NSStringFromSelector(_cmd));
  32. return ;
  33. }
  34. - (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  35. NSLog(@"%@",NSStringFromSelector(_cmd));
  36. UILabel *label = [[UILabel alloc] init];
  37. label.text = @"头标题";
  38. return label;
  39. }
  40. - (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
  41. NSLog(@"%@",NSStringFromSelector(_cmd));
  42. UILabel *label = [UILabel new];
  43. label.text = @"尾标题";
  44. return label;
  45. }

以及UITableViewDataSource的:

  1. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  2.  
  3. NSLog(@"%@",NSStringFromSelector(_cmd));
  4.  
  5. return 2;
  6. }
  7. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  8. static NSString *CellIdentifier = @"Cell";
  9. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  10. if (!cell) {
  11. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
  12. }
  13. cell.textLabel.text = self.contentArray[indexPath.row];
  14. NSLog(@"%@",NSStringFromSelector(_cmd));
  15. return cell;
  16. }
  17.  
  18. //设置section的个数
  19. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  20. NSLog(@"----------------------------------------------------------------------%ld",++inde);
  21. NSLog(@"%@",NSStringFromSelector(_cmd));
  22. return 1;
  23. }
  24. - (nullable NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
  25. NSLog(@"%@",NSStringFromSelector(_cmd));
  26. return @"headerTitle";
  27. }
  28. - (nullable NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section {
  29. NSLog(@"%@",NSStringFromSelector(_cmd));
  30. return @"footerTitle";
  31. }

这里我是讲section得个数设置为1,每个section中的row为2。控制台输出结果如下:

  1. -- ::19.042 UITableViewMethodsTest[:] ----------------------------------------------------------------------
  2. -- ::19.042 UITableViewMethodsTest[:] numberOfSectionsInTableView:
  3. -- ::19.042 UITableViewMethodsTest[:] tableView:heightForHeaderInSection:
  4. -- ::19.043 UITableViewMethodsTest[:] tableView:heightForHeaderInSection:
  5. -- ::19.043 UITableViewMethodsTest[:] tableView:heightForFooterInSection:
  6. -- ::19.043 UITableViewMethodsTest[:] tableView:heightForFooterInSection:
  7. -- ::19.043 UITableViewMethodsTest[:] tableView:numberOfRowsInSection:
  8. -- ::19.043 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  9. -- ::19.043 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  10. -- ::19.048 UITableViewMethodsTest[:] ----------------------------------------------------------------------
  11. -- ::19.049 UITableViewMethodsTest[:] numberOfSectionsInTableView:
  12. -- ::19.049 UITableViewMethodsTest[:] tableView:heightForHeaderInSection:
  13. -- ::19.049 UITableViewMethodsTest[:] tableView:heightForHeaderInSection:
  14. -- ::19.049 UITableViewMethodsTest[:] tableView:heightForFooterInSection:
  15. -- ::19.049 UITableViewMethodsTest[:] tableView:heightForFooterInSection:
  16. -- ::19.049 UITableViewMethodsTest[:] tableView:numberOfRowsInSection:
  17. -- ::19.049 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  18. -- ::19.049 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  19. -- ::19.067 UITableViewMethodsTest[:] ----------------------------------------------------------------------
  20. -- ::19.067 UITableViewMethodsTest[:] numberOfSectionsInTableView:
  21. -- ::19.067 UITableViewMethodsTest[:] tableView:heightForHeaderInSection:
  22. -- ::19.067 UITableViewMethodsTest[:] tableView:heightForHeaderInSection:
  23. -- ::19.067 UITableViewMethodsTest[:] tableView:heightForFooterInSection:
  24. -- ::19.067 UITableViewMethodsTest[:] tableView:heightForFooterInSection:
  25. -- ::19.067 UITableViewMethodsTest[:] tableView:numberOfRowsInSection:
  26. -- ::19.067 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  27. -- ::19.067 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  28. -- ::19.070 UITableViewMethodsTest[:] ----------------------------------------------------------------------
  29. -- ::19.070 UITableViewMethodsTest[:] numberOfSectionsInTableView:
  30. -- ::19.070 UITableViewMethodsTest[:] tableView:heightForHeaderInSection:
  31. -- ::19.070 UITableViewMethodsTest[:] tableView:heightForHeaderInSection:
  32. -- ::19.070 UITableViewMethodsTest[:] tableView:heightForFooterInSection:
  33. -- ::19.071 UITableViewMethodsTest[:] tableView:heightForFooterInSection:
  34. -- ::19.071 UITableViewMethodsTest[:] tableView:numberOfRowsInSection:
  35. -- ::19.071 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  36. -- ::19.071 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  37. -- ::19.072 UITableViewMethodsTest[:] tableView:cellForRowAtIndexPath:
  38. -- ::19.073 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  39. -- ::19.073 UITableViewMethodsTest[:] tableView:willDisplayCell:forRowAtIndexPath:
  40. -- ::19.073 UITableViewMethodsTest[:] tableView:cellForRowAtIndexPath:
  41. -- ::19.074 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  42. -- ::19.074 UITableViewMethodsTest[:] tableView:willDisplayCell:forRowAtIndexPath:
  43. -- ::19.074 UITableViewMethodsTest[:] tableView:viewForHeaderInSection:
  44. -- ::19.074 UITableViewMethodsTest[:] tableView:willDisplayHeaderView:forSection:
  45. -- ::19.074 UITableViewMethodsTest[:] tableView:viewForFooterInSection:
  46. -- ::19.074 UITableViewMethodsTest[:] tableView:willDisplayFooterView:forSection:

从结果可知,当我们设置为1个section和一个每个section的row为2的时候,显示出来一个UITableView的实例需要4轮(我这里用numberOfSectionsInTableView:方法做了分割,所以是4轮):

第一轮~第三轮都是一样的:

1、先执行numberOfSectionsInTableView:一次

2、然后执行tableView:heightForHeaderInSection:两次

3、再执行tableView:heightForFooterInSection:两次

4、再执行tableView:numberOfRowsInSection:一次

5、最后执行tableView:heightForRowAtIndexPath:两次

第四轮是这样的:

1、执行numberOfSectionsInTableView:一次

2、执行tableView:heightForHeaderInSection:两次

3、执行tableView:heightForFooterInSection:两次

4、执行tableView:numberOfRowsInSection:一次

5、执行tableView:heightForRowAtIndexPath:两次

前5步和前三轮是一样的

6、执行tableView:cellForRowAtIndexPath:一次

7、执行tableView:heightForRowAtIndexPath:一次

8、执行tableView:willDisplayCell:forRowAtIndexPath:一次

9、10、11是重复6、7、8。(因为是两个row)

12、执行tableView:viewForHeaderInSection:一次

13、执行tableView:willDisplayHeaderView:forSection:一次

14、执行tableView:viewForFooterInSection:一次

15、执行tableView:willDisplayFooterView:forSection:一次

运行结果如下:(有点丑)

当我们把section设置为2,每个section中row行数为3的时候,控制台输出结果如下:

  1. -- ::27.739 UITableViewMethodsTest[:] ----------------------------------------------------------------------
  2. -- ::27.739 UITableViewMethodsTest[:] numberOfSectionsInTableView:
  3. -- ::27.739 UITableViewMethodsTest[:] tableView:heightForHeaderInSection:
  4. -- ::27.739 UITableViewMethodsTest[:] tableView:heightForHeaderInSection:
  5. -- ::27.740 UITableViewMethodsTest[:] tableView:heightForFooterInSection:
  6. -- ::27.740 UITableViewMethodsTest[:] tableView:heightForFooterInSection:
  7. -- ::27.740 UITableViewMethodsTest[:] tableView:numberOfRowsInSection:
  8. -- ::27.740 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  9. -- ::27.740 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  10. -- ::27.740 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  11. -- ::27.740 UITableViewMethodsTest[:] tableView:heightForHeaderInSection:
  12. -- ::27.741 UITableViewMethodsTest[:] tableView:heightForHeaderInSection:
  13. -- ::27.741 UITableViewMethodsTest[:] tableView:heightForFooterInSection:
  14. -- ::27.741 UITableViewMethodsTest[:] tableView:heightForFooterInSection:
  15. -- ::27.741 UITableViewMethodsTest[:] tableView:numberOfRowsInSection:
  16. -- ::27.741 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  17. -- ::27.741 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  18. -- ::27.742 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  19. -- ::27.756 UITableViewMethodsTest[:] ----------------------------------------------------------------------
  20. -- ::27.756 UITableViewMethodsTest[:] numberOfSectionsInTableView:
  21. -- ::27.757 UITableViewMethodsTest[:] tableView:heightForHeaderInSection:
  22. -- ::27.757 UITableViewMethodsTest[:] tableView:heightForHeaderInSection:
  23. -- ::27.757 UITableViewMethodsTest[:] tableView:heightForFooterInSection:
  24. -- ::27.758 UITableViewMethodsTest[:] tableView:heightForFooterInSection:
  25. -- ::27.758 UITableViewMethodsTest[:] tableView:numberOfRowsInSection:
  26. -- ::27.759 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  27. -- ::27.759 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  28. -- ::27.759 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  29. -- ::27.759 UITableViewMethodsTest[:] tableView:heightForHeaderInSection:
  30. -- ::27.760 UITableViewMethodsTest[:] tableView:heightForHeaderInSection:
  31. -- ::27.760 UITableViewMethodsTest[:] tableView:heightForFooterInSection:
  32. -- ::27.760 UITableViewMethodsTest[:] tableView:heightForFooterInSection:
  33. -- ::27.760 UITableViewMethodsTest[:] tableView:numberOfRowsInSection:
  34. -- ::27.761 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  35. -- ::27.767 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  36. -- ::27.767 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  37. -- ::27.769 UITableViewMethodsTest[:] ----------------------------------------------------------------------
  38. -- ::27.769 UITableViewMethodsTest[:] numberOfSectionsInTableView:
  39. -- ::27.770 UITableViewMethodsTest[:] tableView:heightForHeaderInSection:
  40. -- ::27.770 UITableViewMethodsTest[:] tableView:heightForHeaderInSection:
  41. -- ::27.770 UITableViewMethodsTest[:] tableView:heightForFooterInSection:
  42. -- ::27.770 UITableViewMethodsTest[:] tableView:heightForFooterInSection:
  43. -- ::27.771 UITableViewMethodsTest[:] tableView:numberOfRowsInSection:
  44. -- ::27.771 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  45. -- ::27.771 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  46. -- ::27.771 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  47. -- ::27.771 UITableViewMethodsTest[:] tableView:heightForHeaderInSection:
  48. -- ::27.771 UITableViewMethodsTest[:] tableView:heightForHeaderInSection:
  49. -- ::27.771 UITableViewMethodsTest[:] tableView:heightForFooterInSection:
  50. -- ::27.771 UITableViewMethodsTest[:] tableView:heightForFooterInSection:
  51. -- ::27.772 UITableViewMethodsTest[:] tableView:numberOfRowsInSection:
  52. -- ::27.772 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  53. -- ::27.772 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  54. -- ::27.772 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  55. -- ::27.776 UITableViewMethodsTest[:] ----------------------------------------------------------------------
  56. -- ::27.776 UITableViewMethodsTest[:] numberOfSectionsInTableView:
  57. -- ::27.776 UITableViewMethodsTest[:] tableView:heightForHeaderInSection:
  58. -- ::27.777 UITableViewMethodsTest[:] tableView:heightForHeaderInSection:
  59. -- ::27.777 UITableViewMethodsTest[:] tableView:heightForFooterInSection:
  60. -- ::27.777 UITableViewMethodsTest[:] tableView:heightForFooterInSection:
  61. -- ::27.777 UITableViewMethodsTest[:] tableView:numberOfRowsInSection:
  62. -- ::27.777 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  63. -- ::27.777 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  64. -- ::27.778 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  65. -- ::27.778 UITableViewMethodsTest[:] tableView:heightForHeaderInSection:
  66. -- ::27.778 UITableViewMethodsTest[:] tableView:heightForHeaderInSection:
  67. -- ::27.779 UITableViewMethodsTest[:] tableView:heightForFooterInSection:
  68. -- ::27.779 UITableViewMethodsTest[:] tableView:heightForFooterInSection:
  69. -- ::27.779 UITableViewMethodsTest[:] tableView:numberOfRowsInSection:
  70. -- ::27.779 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  71. -- ::27.780 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  72. -- ::27.781 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  73. -- ::27.784 UITableViewMethodsTest[:] tableView:cellForRowAtIndexPath:
  74. -- ::27.785 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  75. -- ::27.786 UITableViewMethodsTest[:] tableView:willDisplayCell:forRowAtIndexPath:
  76. -- ::27.787 UITableViewMethodsTest[:] tableView:cellForRowAtIndexPath:
  77. -- ::27.787 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  78. -- ::27.789 UITableViewMethodsTest[:] tableView:willDisplayCell:forRowAtIndexPath:
  79. -- ::27.790 UITableViewMethodsTest[:] tableView:cellForRowAtIndexPath:
  80. -- ::27.790 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  81. -- ::27.790 UITableViewMethodsTest[:] tableView:willDisplayCell:forRowAtIndexPath:
  82. -- ::27.791 UITableViewMethodsTest[:] tableView:cellForRowAtIndexPath:
  83. -- ::27.791 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  84. -- ::27.792 UITableViewMethodsTest[:] tableView:willDisplayCell:forRowAtIndexPath:
  85. -- ::27.823 UITableViewMethodsTest[:] tableView:cellForRowAtIndexPath:
  86. -- ::27.824 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  87. -- ::27.824 UITableViewMethodsTest[:] tableView:willDisplayCell:forRowAtIndexPath:
  88. -- ::27.824 UITableViewMethodsTest[:] tableView:cellForRowAtIndexPath:
  89. -- ::27.825 UITableViewMethodsTest[:] tableView:heightForRowAtIndexPath:
  90. -- ::27.825 UITableViewMethodsTest[:] tableView:willDisplayCell:forRowAtIndexPath:
  91. -- ::27.827 UITableViewMethodsTest[:] tableView:viewForHeaderInSection:
  92. -- ::27.828 UITableViewMethodsTest[:] tableView:willDisplayHeaderView:forSection:
  93. -- ::27.828 UITableViewMethodsTest[:] tableView:viewForFooterInSection:
  94. -- ::27.829 UITableViewMethodsTest[:] tableView:willDisplayFooterView:forSection:
  95. -- ::27.910 UITableViewMethodsTest[:] tableView:viewForHeaderInSection:
  96. -- ::27.911 UITableViewMethodsTest[:] tableView:willDisplayHeaderView:forSection:
  97. -- ::27.911 UITableViewMethodsTest[:] tableView:viewForFooterInSection:
  98. -- ::27.911 UITableViewMethodsTest[:] tableView:willDisplayFooterView:forSection:

这里也是执行了4轮。前3轮一样。不过由于有两个section。

第一轮~第三轮都是一样的:

1、执行numberOfSectionsInTableView:一次

2、执行tableView:heightForHeaderInSection:两次

3、执行tableView:heightForFooterInSection:两次

4、执行tableView:numberOfRowsInSection:一次

5、执行tableView:heightForRowAtIndexPath:三次 (因为每个section中有3个row)

重复执行2~5

完毕。

第四轮:

前面的和前三轮是一致的。后面开始执行

续1、执行tableView:cellForRowAtIndexPath:一次

续2、执行tableView:heightForRowAtIndexPath:一次

续3、执行tableView:willDisplayCell:forRowAtIndexPath:一次

重复执行续1~续3 五次。然后继续执行:

续4、执行tableView:viewForHeaderInSection:一次

续5、执行tableView:willDisplayHeaderView:forSection:一次

续6、执行tableView:viewForFooterInSection:一次

续7、执行tableView:willDisplayFooterView:forSection:一次

重复执行续4~续5一次(因为有两个section,所以执行了两次设置header和footer)

完毕

运行结果:(有点丑)

四、注意点

  1、如果在设置header和footer信息的时候,View的优先级高于titile。(Views are preferred over title should you decide to provide both)

  2、如果想让header的title或者footer的title显示不一样的样式(颜色,字体大小),可以用自定义view(UILabel)来实现。

  3、注意复用单元格。  

  4、设置headerTitle样式的时候如果这样写:

  1. - (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  2. NSLog(@"%@",NSStringFromSelector(_cmd));
  3. static NSString *HEADTITLE = @"headerTitle";
  4. UITableViewHeaderFooterView *titleView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:HEADTITLE];
  5. if (titleView == nil) {
  6. titleView = [[UITableViewHeaderFooterView alloc] initWithReuseIdentifier:HEADTITLE];
  7. }
  8. titleView.textLabel.textColor = [UIColor redColor];
  9. titleView.textLabel.text =@"头部标题";
  10. return titleView;
  11. }

其中的textColor设置无效。此时可以在这里设置:

  1. - (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section {
  2. UITableViewHeaderFooterView *vi = (UITableViewHeaderFooterView *)view;
  3. vi.textLabel.textColor = [UIColor redColor];
  4.  
  5. NSLog(@"%@",NSStringFromSelector(_cmd));
  6. }

此方法是将要显示header的时候调用的。从执行顺序可以看出来tableView:viewForHeaderInsection:在tableView:willDisplayHeaderView:forSection:之前调用。但是我在tableView:willDisplayHeaderView:forSection:里面设置为什么设置无效呢?难道是因为他是自适应的原因么?有知道的可以告诉一下。

UITableView代理方知多少+执行顺序的更多相关文章

  1. UITableView的全部属性、方法以及代理方法执行顺序,看过之后肯定有收获---董鑫

    UITableView-------表视图--继承UIScrollView并遵守NSCoding协议 属性 frame-------------设置控件的位置和大小 backgroundColor-- ...

  2. tableView代理方法执行顺序

    tableView代理方法执行顺序,随着iOS系统版本的不断升级,执行顺序也有所变化 1.iOS7.1中先依次调一遍heightForRow方法再依次调一遍cellForRow方法,在调cellFor ...

  3. mysql优化必知(mysql的语句执行顺序)

    MySQL的语句执行顺序 MySQL的语句一共分为11步,如下图所标注的那样,最先执行的总是FROM操作,最后执行的是LIMIT操作.其中每一个操作都会产生一张虚拟的表,这个虚拟的表作为一个处理的输入 ...

  4. UIViewController的生命周期及iOS程序执行顺序 和ios6 处理内存警告

    当一个视图控制器被创建,并在屏幕上显示的时候. 代码的执行顺序1. alloc                                   创建对象,分配空间2.init (initWithN ...

  5. iOS程序执行顺序和UIViewController 的生命周期(整理)

    说明:此文是自己的总结笔记,主要参考: iOS程序的启动执行顺序 AppDelegate 及 UIViewController 的生命周期 UIView的生命周期 言叶之庭.jpeg 一. iOS程序 ...

  6. 浅谈Spring AOP 面向切面编程 最通俗易懂的画图理解AOP、AOP通知执行顺序~

    简介 我们都知道,Spring 框架作为后端主流框架之一,最有特点的三部分就是IOC控制反转.依赖注入.以及AOP切面.当然AOP作为一个Spring 的重要组成模块,当然IOC是不依赖于Spring ...

  7. java-mybaits-013-mybatis-Interceptor-拦截器执行顺序

    一.概述 已知拦截器能够拦截四种类型:Executor.ParameterHandler.ResultSetHandler.StatementHandler. 1.1.不同类型拦截器的执行顺序 背景: ...

  8. MonoBehaviour Lifecycle(生命周期/脚本执行顺序)

    脚本执行顺序 前言 搭建一个示例来验证Unity脚本的执行顺序,大概测试以下部分: 物理方面(Physics) 渲染(Scene rendering) 输入事件(InputEvent) 流程图 Uni ...

  9. Unity中脚本的执行顺序总结(@WhiteTaken)

    (Editor)以上是Unity官方文档中的截图,脚本在被挂载到物体上,会启用Editor的方法Reset. (Initialization)当执行脚本开始,初始化的过程中,依次执行的是Awake-& ...

随机推荐

  1. web框架--bottle

    安装 2 3 4 pip install bottle easy_install bottle apt-get install python-bottle wget http://bottlepy.o ...

  2. 抓取代理IP

    写脚本从指定网站抓取数据的时候,免不了会被网站屏蔽IP.所以呢,就需要有一些IP代理.随便在网上找了一个提供免费IP的网站西刺做IP抓取.本次实践抓取的是其提供的国内匿名代理.可以打开网站查看一下源码 ...

  3. Winform如何实现ComboBox模糊查询

    最近朋友问了一个关于Winform实现ComboBox模糊查询的知识点,自己好久没有搞Winform了,就上手练了一下,废话不多说,进入正题. 前台设计: 前台就是一个简单的Form窗体+一个Comb ...

  4. 使用LinkedList模拟一个堆栈或者队列数据结构

    使用LinkedList模拟一个堆栈或者队列数据结构. 堆栈:先进后出  如同一个杯子. 队列:先进先出  如同一个水管. import java.util.LinkedList; public cl ...

  5. 【原创】.NET Web API之filter ActionFilterAttribute 过滤器使用

    1.在filter类里面引用,与MVC里面的不同 using System.Web.Http.Controllers; using System.Web.Http.Filters; 2.filter类 ...

  6. 插入排序---直接插入排序算法(Javascript版)

    将n个元素的数列分为已有序和无序两个部分. 数列:{a1,a2,a3,a4,…,an} 将该数列的第一元素视为有序数列,后面都视为无序数列: {{a1},{a2,a3,a4,…,an}} 将无序数列中 ...

  7. android The connection to adb is down 错误信息

    之前运行eclipse执行android应用都没问题,今天突然出问题了,控制台报错: The connection to adb is down, and a severe error has occ ...

  8. PHP中利用GD实现的柱状图

    PHP中利用GD实现的柱状图,自己写的一个画柱状图的类,上代码. <?php Class Chart{ private $image; // 定义图像 private $title; // 定义 ...

  9. JQuery的调用

    在head标签中引用一个JQuery的文件用以制作鼠标点击动画,(JQuery包可从网上下载)   JS包,脚本语言 <script language="javascript" ...

  10. mysql Access denied for user root@localhost错误解决方法总结(转)

    mysql Access denied for user root@localhost错误解决方法总结(转) mysql Access denied for user \'root\'@\'local ...