UITableView beginUpdate和endUpdate使用的前提
转载地址: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使用的前提的更多相关文章
- ListView的BeginUpdate()和EndUpdate()作用[z]
[z]https://blog.csdn.net/u011108093/article/details/79448060 许多Windows 窗体控件(例如,ListView 和 TreeView 控 ...
- ListView的BeginUpdate()和EndUpdate()的用处
许多Windows 窗体控件(例如,ListView 和 TreeView 控件)实现了 BeginUpdate 和EndUpdate 方法,至于为何要这样用简单说明一下. 当我们向一个Listvie ...
- UITableView出现卡顿如何处理
tableView的beginUpdate和endUpdate要比reloadData和reloadRowsAtIndexPaths好,因为beginUpdate和endUpdate会执行一个动画bl ...
- AspxGridView使用手记
AspxGridView使用手记 一. 基本使用方法 4 1.导入Dll文件 4 2.Asp.Net页面控件注册 4 3. Asp.Net页面控件声明 5 4.删除licenses. ...
- Delphi TListView刷新闪烁问题
应用场景 TListView可以动态选择列并显示而且列宽度也要保存,加载数据ListView会出现N次闪烁 步骤一: 选择要显示列: 点击"确定"按钮,显示下图 步骤二: 界面会出 ...
- 多节点ListView的加载效率
据说实际场景中node数量达到4k~6k,ListView就崩溃了.(怎么个崩溃法未知) 小试了一下,10w个node毫无压力.(win7 vs2010 .net2.0) 有意思的地方在于,动态添加如 ...
- 一个继承TList的例子
类声明部分: TDMSTrains = class(TList) private FHashed: Boolean; FHashList: TFpHashList; FOwnsObjects: Boo ...
- Delphi Alpha皮肤控件使用方法
//用于刷新控件颜色. FsSkinManager.BeginUpdate; FsSkinManager.EndUpdate(True); //动态选择皮肤 begin if not FIsswitc ...
- NetAdvantage 笔记
1.UltraControlBase Class Members 1.BeginUpdate Method Sets the IsUpdating flag to true which prevent ...
随机推荐
- js事件冒泡原理及处理
事件从根节点开始,逐级派送到子节点,若节点绑定了事件动作,则执行动作,然后继续走,这个阶段称为“捕获阶段(Capture)”:执行完捕获阶段后,事件由子节点往根节点派送,若节点绑定了事件动作,则执行动 ...
- chrome:// 的秘密!!一些有用的命令!
chrome:// .......命令 集结 Chrome 有很多的特性在界面菜单中是没有体现的,可以通过 chrome:// 命令来访问 我搜集了下面这些!!!当然也是在网上找的!有的我自己也不知道 ...
- winfrom获得鼠标的坐标
Point mouse = this.PointToScreen(Control.MousePosition);label1.Text = mouse.X.ToString() + ":&q ...
- LightOj_1030 Discovering Gold
题目链接 题意: 在一个1 X N 的格子上, 每个格子都有一定的黄金, 你从第一个格子出发, 问到最后一个格子得到黄金的期望. 每次前进使用骰子投点来决定前进步数, 如果投出的点前进后会超过N, 那 ...
- python 学习笔记整理
首先自我批评一下,说好的一天写一篇博客,结果不到两天,就没有坚持了,发现自己做什么事情都没有毅力啊!不能持之以恒.但是,这次一定要从写博客开始来改掉自己的一个坏习惯. 可是写博客又该写点什么呢? 反正 ...
- 【POJ11855】 Buzzwords (后缀数组)
Description The word “the” is the most commonthree-letter word. It evenshows up inside other words, ...
- Class.forName()的理解
转自:http://blog.csdn.net/yanwushu/article/details/7574713 使用jdbc方式连接数据库时会使用一句代码Class.forName(String c ...
- Android 每天定时提醒功能实现
android要实现定时的功能那肯定就要用到闹铃相关的技术, 那么android闹铃实现是基于 AlarmManager 这个类的,首先我们来看一下它的几个主要的方法. 打开AlarmManager的 ...
- python手记(30)
#!/usr/bin/env python #-*- coding: utf-8 -*- import cv2 import numpy as np fn="test3.png" ...
- 【转】Android ProgressDialog的使用
原文网址:http://blog.csdn.net/sjf0115/article/details/7255280 版权声明:本文为博主原创文章,未经博主允许不得转载. <1>简介 Pro ...