ios 解决bug---UITableView删除到最后一个unable to generate a new section map with old section count: 1 and new
来源:互联网 发布:mac上好玩的单机游戏 编辑:程序博客网 时间:2024/05/18 19:39
在iOS的UItableview删除中,删除操作我们经常用这样的语句
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UITableViewCellEditingStyleDelete) { [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; } else if (editingStyle == UITableViewCellEditingStyleInsert) { // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view. } }
但是每次删除到最后一行时就会报错,报错提示是这样的:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView internal bug: unable to generate a new section map with old section count: 1 and new section count: 0'
这是因为 tableView 是分组的,删除最后一个分组中最后一个cell 和数据源时 也要对 session 进行操作
正确的处理方法为:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { [tableView beginUpdates]; if (editingStyle == UITableViewCellEditingStyleDelete) { [tableView deleteSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationLeft]; } [tableView reloadData]; else if (editingStyle == UITableViewCellEditingStyleInsert) { } [tableView endUpdates];}
[tableView beginUpdates];
[tableView endUpdates];并且还需要对最后一个section做删除操作
[tableView deleteSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationLeft];
0 0
- ios 解决bug---UITableView删除到最后一个unable to generate a new section map with old section count: 1 and new
- iOS-分组UITableView删除崩溃问题(当删除section中最后一条数据崩溃的情况)
- 关于UITableView的section最后一个分割线的优化
- Out With the Old and in With the New
- Unable to generate a temporary class (result=1)解决
- iOS UITableView设置Section间距
- iOS UITableview 只刷新一个cell 或 section
- 解决E: Encountered a section with no Package: header错误
- 解决E: Encountered a section with no Package: header
- 解决ubuntu E: Encountered a section with no Package: header
- 解决E: Encountered a section with no Package: header
- 解决Encountered a section with no Package: header错误
- 解决E: Encountered a section with no Package: header
- old 10.10 to new linux
- 3 Sure-Fire Ways to Generate New and Great Ideas
- [iOS UItableView 自定义Section] 自定义Section 修改title样式
- how to begin with a new project
- UITableView 滚动到指定行 section
- iOS-模拟响应者链,自己hittest方法
- 使用OneNote的COM组件,实现OCR功能。
- node.js编写c/c++模块
- 关于QtSerialPort编译在Qt4.8.6+Qt creator+Win7 / XP环境下的总结
- GCC编程四个过程:预处理-编译-汇编-链接
- ios 解决bug---UITableView删除到最后一个unable to generate a new section map with old section count: 1 and new
- xcode 删除模拟器 Simulator
- XXX could not be redeployed because it could not be completely removed
- React Native 之生命周期
- Druid连接池自定义数据库密码加解密的实现
- Java的native方法是什么
- Linux系统移植实验---SD卡驱动移植
- ArcGIS 10.3 属性表乱码问题
- :target 伪类使用技巧