转载地址:http://blog.csdn.net/vieri_ch/article/details/46893023

UITableView有两个方法,用于单元格动画变化的方法,beginUpdate,endUpdate,这两个方法使用时需要注意。如果使用不当,会造成crash

在了解使用注意事项之前,我们先看官方文档的描述。

Call this method if you want subsequent insertions, deletion, and

selection operations (for example, cellForRowAtIndexPath: and

indexPathsForVisibleRows) to be animated simultaneously. You can also

use this method followed by the endUpdates method to animate the

change in the row heights without reloading the cell. This group of

methods must conclude with an invocation of endUpdates. These method

pairs can be nested. If you do not make the insertion, deletion, and

selection calls inside this block, table attributes such as row count

might become invalid. You should not call reloadData within the group;

if you call this method within the group, you must perform any

animations yourself.

从描述中,可以了解到以下几点

1. 这个方法用于在调用插入,删除,选择方法时,同时有动画效果。

2. 用endUpdate能动画改变行高,而无需relaod这个cell。

3. beginUpdate和endUpdate成对使用,其包含的block里面,如果没有插入删除,选择的方法被使用。有可能导致这个table view的一些属性失效,例如行的数量。

4. 不应该在这个block范围里调用 reloadData,或者reloadRowsAtIndexPaths。一旦使用,必须自己执行和管理自己的动画效果。

第三点和第四点比较重要。也是导致闪退的原因。reloadData会引起,获取单元格高度,以及cell的重新加载。这会导致一些动画对应的行号产生变化。从而闪退。

UITableView beginUpdate和endUpdate使用的前提的更多相关文章

  1. ListView的BeginUpdate()和EndUpdate()作用[z]

    [z]https://blog.csdn.net/u011108093/article/details/79448060 许多Windows 窗体控件(例如,ListView 和 TreeView 控 ...

  2. ListView的BeginUpdate()和EndUpdate()的用处

    许多Windows 窗体控件(例如,ListView 和 TreeView 控件)实现了 BeginUpdate 和EndUpdate 方法,至于为何要这样用简单说明一下. 当我们向一个Listvie ...

  3. UITableView出现卡顿如何处理

    tableView的beginUpdate和endUpdate要比reloadData和reloadRowsAtIndexPaths好,因为beginUpdate和endUpdate会执行一个动画bl ...

  4. AspxGridView使用手记

    AspxGridView使用手记   一.  基本使用方法  4 1.导入Dll文件   4 2.Asp.Net页面控件注册 4 3. Asp.Net页面控件声明    5 4.删除licenses. ...

  5. Delphi TListView刷新闪烁问题

    应用场景 TListView可以动态选择列并显示而且列宽度也要保存,加载数据ListView会出现N次闪烁 步骤一: 选择要显示列: 点击"确定"按钮,显示下图 步骤二: 界面会出 ...

  6. 多节点ListView的加载效率

    据说实际场景中node数量达到4k~6k,ListView就崩溃了.(怎么个崩溃法未知) 小试了一下,10w个node毫无压力.(win7 vs2010 .net2.0) 有意思的地方在于,动态添加如 ...

  7. 一个继承TList的例子

    类声明部分: TDMSTrains = class(TList) private FHashed: Boolean; FHashList: TFpHashList; FOwnsObjects: Boo ...

  8. Delphi Alpha皮肤控件使用方法

    //用于刷新控件颜色. FsSkinManager.BeginUpdate; FsSkinManager.EndUpdate(True); //动态选择皮肤 begin if not FIsswitc ...

  9. NetAdvantage 笔记

    1.UltraControlBase Class Members 1.BeginUpdate Method Sets the IsUpdating flag to true which prevent ...

随机推荐

  1. In Place Upgrade of CentOS 6 to CentOS 7

    Note: This is not the most highly recommended method to move from CentOS 6 to CentOS 7 ... but it ca ...

  2. linux之GDB常用命令汇总

    查看gdb的版本号 (1)rpm -q gdb 会显示是否安装gdb及版本号 (2)gdb --version也可以 breakpoint b main; b 20; 设置断点 breakpoint ...

  3. nRF52系列——Get started

    Install Jlink Install MDK 这里的使用的是MDK 5.14 Install SDK https://developer.nordicsemi.com/nRF52_SDK/ 这里 ...

  4. VS2013相关资料

    visual studio 主页 http://msdn.microsoft.com/en-us/vstudio/aa718325.aspx vs2013 download http://www.mi ...

  5. PyCharm使用技巧记录(一)如何查看变量

    [为了方便自己以后查阅,记录下使用PyCharm时的一些小技巧] 正在学习Python,在调试Python程序时,遇到了一个非常大的问题:如何能够方便地查看变量的取值呢? 由于使用matlab多年,深 ...

  6. hdu 2012 素数判定 Miller_Rabbin

    素数判定 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...

  7. asp.net关于Cookie跨域(域名)的问题

    Cookie是一个伟大的发明,它允许Web开发者保留他们的用户的登录状态.但是当你的站点有一个以上的域名时就会出现问题了.在Cookie规范上 说,一个cookie只能用于一个域名,不能够发给其它的域 ...

  8. c++ 名字粉碎(name mangling)

    转自Ibm: Name mangling is the encoding of function and variable names into unique names so that linker ...

  9. 【HDOJ】1150 Machine Schedule

    匈牙利算法. #include <stdio.h> #include <string.h> #define MAXNUM 1005 char map[MAXNUM][MAXNU ...

  10. quartz 两次执行问题

    最近发现网站(xiayule.net)越写越大,有些东西已经难以维护了,想要添加个功能,都得斟酌半天 项目中有很多可重构的地方,小重构一直进行,大的不敢动,毕竟没有很多时间做测试. 最后,决定精简代码 ...