转载地址: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. Find your present (2) (位异或)

    Problem Description In the new year party, everybody will get a "special present".Now it's ...

  2. RestKit:iOS开发必备,告别众多无聊代码

    http://www.csdn.net/article/2014-04-15/2819312-RestKit-frameworkRestKit是一款专为iOS设计的Objective-C框架,旨在与R ...

  3. http server v0.1_mime.c

    #include <string.h> #include "mime.h" static STR_MIME_MAP mime_map[]= { MIME_MAP(MIM ...

  4. [BZOJ 1098] [POI2007] 办公楼biu 【链表优化BFS】

    题目链接:BZOJ - 1098 题目分析 只有两个点之间有边的时候它们才能在不同的楼内,那么就是说如果两个点之间没有边它们就一定在同一座楼内. 那么要求的就是求原图的补图的连通块. 然而原图的补图的 ...

  5. Prefixes and Suffixes

    Codeforces Round #246 (Div. 2) D:http://codeforces.com/contest/432/problem/D 题意:给你一个长度不超过10^5的字符串.要你 ...

  6. kafka java示例

    http://www.open-open.com/lib/view/open1407942131801.html http://www.open-open.com/lib/view/open14079 ...

  7. 代理Delegate的小应用(代理日期控件和下拉框)

    前言 在平时关于表格一类的的控件使用中,不可避免需要修改每个Item的值,通过在Item中嵌入不同的控件对编辑的内容进行限定,然而在表格的Item中插入的控件始终显示,当表格中item项很多的时候,会 ...

  8. [性能分析]linux文件描述符(转)

    1.什么是文件和文件描述符 Linux中文件可以分为4种:普通文件.目录文件.链接文件和设备文件.1.普通文件是用户日常使用最多的文件,包括文本文件.shell脚本.二进制的可执行和各种类型的数据.l ...

  9. PL/SQL 异常处理

    SQL> set serveroutput on SQL> declare   name varchar2(10); begin   select ename into name from ...

  10. bzoj1819

    水题,上trie,然后穷举每一位的时候判定一下三种编辑 ..*,..] of longint; v:..*] of longint; d:..] of boolean; s:string; t,i,l ...