转载地址: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. git 创建多个账户ssh

    创建一个账户 创建ssh本地秘钥. $ ssh-keygen -t rsa -C "youremail@xxx.com" 一路回车,会在~/.ssh/目录下生成id_rsa和id_ ...

  2. 简单学C——第七天

    函数 函数是C语言重要的组成部分,你现在,或者以后(如果C没什么变化的话)所写的任何一个C语言程序都是由一个一个的函数组合在一起的,当然,现在或许你只会在主函数 main中写一个小程序,那么在看了本篇 ...

  3. Coursera《machine learning》--(6)逻辑回归

    六 逻辑回归(Logistic Regression:LR) 逻辑回归(Logistic Regression, LR)模型其实仅在线性回归的基础上,套用了一个逻辑函数,但也就是由于这个逻辑函数,使得 ...

  4. Hadoop 2.6.0编译on mac

    花了一个晚上的时间弄了下hadoop的编译环境,碰到些错误,这里保存下. 需要编译Hadoop,不但需要安装Maven,还需要安装protobuf 安装Maven 下载:apache-maven-3. ...

  5. 高性能页面加载技术(流水线加载)BigPipe的C#简单实现(附源码)

    一,BigPipe简介 BigPipe是一个重新设计的基础动态网页服务体系.大体思路是,分解网页成叫做Pagelets的小块,然后通过Web服务器和浏览器建立管道并管理他们在不同阶段的运行.这是类似于 ...

  6. [BZOJ 2127] happiness 【最小割】

    题目链接:BZOJ - 2127 题目分析 首先,每个人要么学文科,要么学理科,所以可以想到是一个最小割模型. 我们就确定一个人如果和 S 相连就是学文,如果和 T 相连就是学理. 那么我们再来确定建 ...

  7. QSplashScreen开机画面(不断的repaint)

    QApplication a(argc, argv);    QPixmap pixmap(":/Image/start.png");//绑定启动图片    QSplashScre ...

  8. delphi 连接 c++ builder 生成obj文件

    delphi 连接 c++ builder 生成obj文件 delphi 可以连接c++ builder 生成OMF格式的obj文件,会报一个错.[DCC Error] E2065 Unsatisfi ...

  9. Android开源项目发现--- 工具类依赖注入DI篇(持续更新)

    通过依赖注入减少View.服务.资源简化初始化,事件绑定等重复繁琐工作 1. AndroidAnnotations(Code Diet) android快速开发框架 项目地址:https://gith ...

  10. lc面试准备:Remove Duplicates from Sorted List

    1 题目 Given a sorted linked list, delete all duplicates such that each element appear only once. For ...