NSInternalInconsistencyException attempt to delete row 2 from section 4 which only contains 0 rows before the update 问题原因
insertRowsAtIndexPaths 和 deleteRowsAtIndexPaths 同 numberOfRowsInSection 的关系
如果不处理好这个关系,大概所有的问题都是这样的:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 6. The number of rows contained in an existing section after the update (0) must be equal to the number of rows contained in that section before the update (9), plus or minus the number of rows inserted or deleted from that section (0 inserted, 3 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to delete row 2 from section 4 which only contains 0 rows before the update'
大楖是说,numberOfRowsInSection 返回的数字和 insert / delete 后,section 所包含的行数不一致。
在 tableView 的 endUpdates 方法之前,应该对标志变量做处理。endUpdates 后,会重新刷新 tableView ,numberOfRowsInSection 会重新被调用。
解决方法有两种:
1,如上所说处理好标志变量:
if ([wwtableview numberOfRowsInSection:4]>2) {}
2,tableview beginUpdates之前的行数对应的是前一个数据源,开始reloadcell时tableview并不知道数据源发生了变化
[wwtableview reloadData]
NSInternalInconsistencyException attempt to delete row 2 from section 4 which only contains 0 rows before the update 问题原因的更多相关文章
- Matlab Delete Row or Col 删除矩阵的行或列
Matlab中,我们有时候要删除矩阵中的某行某列,可以采用下列方法进行删除: a = [ ]; a(,:) = []; % Delete row a(:,) = []; % Delete col
- iOS 关于UITableView的黑科技
UITableView是我们最常用的控件了,今天我就来介绍一些关于UITableView的黑科技和一些注意的地方. 1.修改左滑删除按钮的高度 左滑删除这是iOS最先发明的,之后安卓开始模仿. ...
- iOS UITableViewController出现crash
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to de ...
- WinForm常用代码
//ToolStripSplitButton是标准按钮和下拉按钮的组合,各自工作,但有联系,感觉上后者是没有向下箭头ToolStripDropDownButton:ToolStripDropDownB ...
- MySQL 系列(四)主从复制、备份恢复方案生产环境实战
第一篇:MySQL 系列(一) 生产标准线上环境安装配置案例及棘手问题解决 第二篇:MySQL 系列(二) 你不知道的数据库操作 第三篇:MySQL 系列(三)你不知道的 视图.触发器.存储过程.函数 ...
- Oracle事务
Oracle事务的ACID特性 原子性Atomicity:事务中的所有动作要么都发生,要么都不发生. 一致性Consistency:事务将数据库从一种状态转变为下一种一致状态. 隔离性Isolatio ...
- PostgreSQL function examples
warehouse_db=# CREATE TABLE warehouse_tbl(warehouse_id INTEGER NOT NULL,warehouse_name TEXT NOT NULL ...
- 基本开题的感觉是了-MySQL继续继续(自定义函数&存储过程)
hi 感觉论文开题基本确定了,凯森 1.MySQL -----自定义函数----- ----基本 两个必要条件:参数和返回值(两者没有必然联系,参数不一定有,返回一定有) 函数体:合法的SQL语句:以 ...
- MySQL安全问题(防范必知)
对于任何一种数据库来说,安全问题都是非常重要的.如果数据库出现安全漏洞,轻则数据被窃取,重则数据被破坏,这些后果对于一些重要的数据库都是非常严重的.下面来从操作系统和数据库两个层对MySQL的安全问题 ...
随机推荐
- pypi 的使用
关于本人的package,情况比较简单,所有的.py文件全部放到了一个叫做FundsData的文件夹下(package下),上层目录也叫FundsData(其实叫什么都可以),其下放了setup.py ...
- Struts2接受参数的几种类型和接受复杂类型参数(list<String>和list<Object>)
Struts2接受参数的几种类型 大概有这几种类型: 1.使用Action的属性接受参数 在Action中加入成员变量,配置Getter和Setter方法,Getter而和Setter方法的名字和表单 ...
- iOS 导航栏不可点击
self.navigationController.navigationBar.userInteractionEnabled = NO;
- Variation of e.touches, e.targetTouches and e.changedTouches
We have the following lists: touches: A list of information for every finger currently touching the ...
- Core Data使用之一(Swift): 保存
Core Data 用于永久化数据,它是基于SQLite数据库的保存一门技术. 那么,在Swift中,它是如何实现的呢? 首先,需要新建一个模板,打开工程中的xcdatamodeld文件,点击“Add ...
- C# Winform窗口之间传值的多种方法浅析(转)
摘要http://www.jb51.net/article/63837.htm 这篇文章主要介绍了C# Winform窗口之间传值的多种方法浅析,本文起讲解了通过构造器传值.通过属性传递.通过事件携带 ...
- ios自定义UIButton内部空间Rect
- Swoole:重新定义PHP
Swoole PHP语言的高性能网络通信框架,提供了PHP语言的异步多线程服务器,异步TCP/UDP网络客户端,异步MySQL,数据库连接池,AsyncTask,消息队列,毫秒定时器,异步文件读写,异 ...
- AngularJS中$http服务的简单用法
我们可以使用内置的$http服务直接同外部进行通信.$http服务只是简单的封装了浏览器原生的XMLHttpRequest对象. 1.链式调用 $http服务是只能接受一个参数的函数,这个参数是一个对 ...
- jQuery 鼠标滚轮插件 jquery.mousewheel.js
jQuery Mousewheel Plugin,用于添加跨浏览器的鼠标滚轮支持.mousewheel事件的处理函数有一点小小的变化,它除了第一个参数event 外,还接收到第二个参数delta.通过 ...