转载地址: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. JavaScriptCore-b

    JavaScriptCore提供了JavaScript和Objective-C桥接的Obj-C API.JavaScriptCore提供了让我们脱离UIWebView执行JavaScript脚本的能力 ...

  2. initWithCoder: 与initWithFrame:

    之前一直用代码来编写画面,现在着手使用storyboard和xib来构筑画面,遇到initWithCoder方法, 故查了下,initWithCoder方法的调用,看了篇博客,链接如下: http:/ ...

  3. 【POJ3208】 (DP)

    Apocalypse Someday Description The number 666 is considered to be the occult “number of the beast” a ...

  4. 【HDU3440】House Man (差分约束)

    题目: Description In Fuzhou, there is a crazy super man. He can’t fly, but he could jump from housetop ...

  5. Junit4学习笔记

    一.初始化标注 在老Junit4提供了setUp()和tearDown(),在每个测试函数调用之前/后都会调用. @Before: Method annotated with @Before exec ...

  6. 字符串模式匹配算法——BM、Horspool、Sunday、KMP、KR、AC算法一网打尽

    字符串模式匹配算法——BM.Horspool.Sunday.KMP.KR.AC算法一网打尽 本文内容框架: §1 Boyer-Moore算法 §2 Horspool算法 §3 Sunday算法 §4 ...

  7. HDFS文件系统基本文件命令、编程读写HDFS

    基本文件命令: 格式为:hadoop fs -cmd <args> cmd的命名通常与unix对应的命令名相同.例如,文件列表命令: hadoop fs -ls 1.添加目录和文件 HDF ...

  8. Win8.1、Office2013一键激活工具

    Win8.1.Office2013一键激活工具 KMSpico V7.0 是一款激活Win8.Windows8.1和Office2013的工具,由国外网友heldigard基于KMSEmulator制 ...

  9. 精通iOS开发(第5版)

    <精通iOS开发(第5版)> 基本信息 原书名:Beginning ios 6 development:exploring the ios sdk 作者: (美)David Mark   ...

  10. bzoj1816

    这道题不是很难,二分答案+判定即可 注意在一套牌中Joker只能用一次 ..] of longint;     mid,l,r,n,m,i,ans:longint; function check(x: ...