deleteRowsAtIndexPaths的NSInternalInconsistencyException异常
来源:互联网 发布:王凯整容了吗 知乎 编辑:程序博客网 时间:2024/06/07 10:05
在表视图的行删除操作中,用deleteRowsAtIndexPaths方法删除一个indexPath数组时,抛出一个错误NSInternalInconsistencyException。将出错前后的代码摘录如下。
[self beginUpdates];
[self deleteRowsAtIndexPaths:@[[self indexPathForCell:cell]]withRowAnimation:UITableViewRowAnimationFade];
[self endUpdates];
[self.dsItems removeObject:_originalShpItem];
使用断点追踪时,发现抛错代码在endUpdates方法上。
错误信息如下:
** Terminating app due to uncaught exception'NSInternalInconsistencyException', reason: 'Unable to resolve row for indexpath: 2 indexes [0, 1]'
先确定一点,这个错是在对于uitableview的机制使用上不熟悉导致的,一定不是uitableview的自生问题,别动不动怀疑ios的bug。
有人这么建议的:
The table view data source needs to be consistent with yourinsert/delete calls. Set a break point in numberOfRowsInSection to assure thatthe number of rows in a section is correct after the insert/delete rows.
表视图的数据源需要和你插入或者删除的操作保持一致。在numberOfRowsInSection上做一个断点,确认插入或者删除记录后结果集总数要和deleteRowsAtIndexPaths操作一致。
通过设置numberOfRowsInSection断点,可以很清楚看到deleteRowsAtIndexPaths的执行流程,它在endUpdates之前,是要调用numberOfRowsInSection的,从而得到删除cell后的记录数。
如果这里没有beginUpdates和endUpdates的封装,那么必须在deleteRowsAtIndexPaths之前就将datasource进行删除。否则就会报这个错误。
至于有人提到,不用deleteRowsAtIndexPaths操作,而是使用reloaddata,全屏
- deleteRowsAtIndexPaths的NSInternalInconsistencyException异常
- 未捕获的异常 'NSInternalInconsistencyException'
- deleteRowsAtIndexPaths
- insertRowsAtIndexPaths 和 deleteRowsAtIndexPaths 的使用
- iOS调用reloadRowsAtIndexPaths Crash报异常NSInternalInconsistencyException
- iOS调用reloadRowsAtIndexPaths Crash报异常NSInternalInconsistencyException
- 调用deleteRowsAtIndexPaths:withRowAnimation:崩溃的问题
- 删除tableview的cell时 deleteRowsAtIndexPaths崩溃
- IOS -- 调用deleteRowsAtIndexPaths:withRowAnimation:崩溃的问题
- 自己新建xib文件后报NSInternalInconsistencyException异常
- iOS开发:UITableView的deleteRowsAtIndexPaths方法的使用
- [ tableView deleteRowsAtIndexPaths:array withRowAnimation:UITableViewRowAnimationRight ]; 执行的顺序
- 用sdk3.0编译运行 UITableView deleteRowsAtIndexPaths的时候就挂掉
- 调用删除方法UITableView deleteRowsAtIndexPaths的时候就挂掉
- 调用删除方法UITableView deleteRowsAtIndexPaths的时候就挂掉
- deleteRowsAtIndexPaths崩溃
- IOS 'NSInternalInconsistencyException'
- iOS deleteRowsAtIndexPaths报错
- 模2除法
- 75.二叉树两个结点的最低共同父结点
- How to generate gcc debug symbol outside the build target?
- 日语“比较”句型
- 使用 Socket 通信实现 FTP 客户端程序
- deleteRowsAtIndexPaths的NSInternalInconsistencyException异常
- 使用gdbserver远程调试
- 利用图形加速可令java提速10倍
- 去除网页中代码的行号
- UVA之102 - Ecological Bin Packing
- BSP概念
- 剑指offer总结——1
- 关于sync_with_stdio(false);
- 微信平台 签名生成工具