iOS-分组UITableView删除崩溃问题(当删除section中最后一条数据崩溃的情况)
错误: The number of sections contained in the table view after the update (1) must be equal to the number of sections contained in the table view before the update (2), plus or minus the number of sections inserted or deleted (0 inserted, 0 deleted).
*** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-2372/UITableView.m:1070
libc++abi.dylib: handler threw exception
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return [_arrKeys count];// _arrKeys中存放分组
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
NSString* _date = [_arrKeys objectAtIndex:section];
NSArray* _notifications = [_dictData objectForKey:_date];// _dictData存放数据
return [_notifications count];
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath*)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
[self refreshData];// 刷新_arrKeys和_dictData中的数据
int newCount=0;
if (indexPath.section<[_arrKeys count]) {
NSString *_date = [_arrKeys objectAtIndex:indexPath.section];
NSArray* _notifications = [_dictData objectForKey:_date];// _dictData存放数据
newCount= [_notifications count];
}
[tableView beginUpdates];
if (newCount<=0) {
[tableView deleteSections:[NSIndexSetindexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationLeft];
}
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]withRowAnimation:UITableViewRowAnimationLeft];
[tableView endUpdates];
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// 修改时
}
}
iOS-分组UITableView删除崩溃问题(当删除section中最后一条数据崩溃的情况)的更多相关文章
- Bag标签之删除书包中的一条数据
删除书包中的一条数据 查询 <esql module=help id=list> Select ID,Subject,Writer,DayTime From Messages </e ...
- mysql中删除重复记录,并保留重复数据中的一条数据的SQL语句
正好想写一条删除重复语句并保留一条数据的SQL,网上查了一部分资料写的很详细,但还是在这里写下自己的理解,以遍后续学习 .如下: 表字段和数据: SQL语句: [sql] view plain cop ...
- mysql在group by分组后查询第二条/第三条乃至每组中任意一条数据
昨天老板让我查询项目中(众筹),没人刚发起感召后,前三笔钱的入账时间和金额,这把大哥整懵逼了,group by在某些方面是好使,但这次不能为我所用了,获取第一笔进账是简单,可以用group by 直接 ...
- ACCESS删除datagridview和数据库中的一条数据,同时更新显示的方法源码
//删除,行删除 private void 删除_Click(object sender, EventArgs e) { int dgrcount = dataGridView1.SelectedRo ...
- sql 选取每个分组中的第一条数据
--1.创建测试表Create Table #Order1( OrderName varchar(50), RequestDate datetime, OrderCount int)-- 插入测试数据 ...
- oracle 根据字段分组取第一条数据及rank函数说明
当前有这样一个需求,根据外键对子表数据进行分组,取每组中的一条数据就行了,如图: 如:COMMANDID = 26的有两条,只取一条数据. sql语句: select * from(select SY ...
- UITableVIew与UICollectionView带动画删除cell时崩溃的处理
UITableVIew与UICollectionView带动画删除cell时崩溃的处理 -会崩溃的原因是因为没有处理好数据源与cell之间的协调关系- 效果: tableView的源码: ModelC ...
- iOS - UITableView 编辑(cell的插入, 删除, 移动)
UITableView Cell的插入/删除 核心API Class : UITableView Delegate : UITableViewDataSource, UITableViewDelega ...
- iOS文件和文件夹的创建,删除,移动, 拷贝,是否存在及简单数据类型的读写
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launc ...
随机推荐
- MySQL优化具体
1. 查询与索引优化分析 在优化MySQL时,通常需要对数据库进行分析,常见的分析手段有慢查询日志,profiling分析,EXPLAIN分析查询,以及show命令查询系统状态及系统变量,通过定位分析 ...
- wamp 环境下配置多台虚拟主机
首先启动wamp,成功之后,单击图标,找到Apache服务器下的 httpd.conf ,直接打开 按下Ctrl+F键,在搜索框中搜索 Virtual hosts, 搜寻结果如下图: 3. 然后打开w ...
- ubuntu 18.04在更新软件库时出现E: Release file for http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease is not valid yet...
1.完整的错误信息如下: E: Release file for http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease i ...
- Material Design学习之 Camera
转载请注明出处:王亟亟的大牛之路 年后第一篇,自从来了某司产量骤减,这里批评下自己,这一篇的素材来源于老牌Material Design控件写手afollestad的 https://github.c ...
- jQuery的$.each()遍历checkbox
$("input[type='checkbox']").each(function(){ var value = $(this).val(); //获得值 $(this).attr ...
- .NET中常见的锁 笔记
Lock.Monitor lock和Monitor的区别 1.lock的底层本身是Monitor来实现的,所以Monitor可以实现lock的所有功能. 2.Monitor有TryEnter的功能,可 ...
- xdebug 常用函数
转自:http://blog.csdn.net/samxx8/article/details/7050282 string xdebug_call_class()返回当前被调用的函数或方法所属的类的类 ...
- 1-27 awk 基本使用
大纲: 色彩: awk基本使用 ##################################################### 一.色彩:shell中,设置输出文本色彩(前景色,背景色) ...
- hack games
记下,有时间玩玩~ wargame http://www.wechall.net/lang_ranking/en --------------- Monyer系列(黑客游戏) 1. http://mo ...
- PyCharm在win10的64位系统安装实例
搭建环境 1.win10_X64,其他Win版本也可以. 2.PyCharm版本:Professional-2016.2.3. 搭建准备 1.到PyCharm官网下载PyCharm安装包. 2.选择W ...