UITableView beginUpdate和endUpdate使用的前提
来源:互联网 发布:手机淘宝怎么找人代付 编辑:程序博客网 时间:2024/05/05 10:13
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()的用处
- BeginUpdate()和EndUpdate()
- BeginUpdate和EndUpdate作用
- TreeView和ListView用到的BeginUpdate()和EndUpdate()的作用
- Delphi中BeginUpdate和EndUpdate作用
- CPaintDC及其与BeginUpdate、EndUpdate的前因后果
- paip.提升性能---.net listbox 使用BeginUpdate与EndUpdate
- BeginUpdate()
- 使用 expdp 的前提
- UITableView的创建和使用
- UITableView的使用规则和技巧等
- UITableView中textLabel和detailTextLabel的使用
- UITableView中textLabel和detailTextLabel的使用
- UITableView中textLabel和detailTextLabel的使用
- uitableview beginupdates 和endupdates 的使用
- UITableView beginUpdates和endUpdates的使用
- Masonry和UITableView-FDTemplateLayoutCell的结合使用
- win7 64位系统bugzilla故障管理平台搭建过程
- Windows8.1 ubuntu14.04双系统安装
- WeakHashMap原理分析
- STL总结
- OpenCV仿射变换+投射变换+单应性矩阵
- UITableView beginUpdate和endUpdate使用的前提
- GCD部分用法
- 接口interface
- java基本教程之线程休眠 java多线程教程
- WINCE蓝牙如何检测被其他设备发起配对请求
- GRE写作必备句型
- 2012年5月SAT香港真题解析
- Django: CSRF verification failed. Request aborted.
- intellij pom.xml web.xml 配置文件莫名的全报错