iOS开发bug消灭之:Invalid update: invalid number of rows in section 0.
2016-10-05 10:14
531 查看
Invalid update: invalid number of rows in section 0.
swift版本:3.0Xcode版本:8.0
错误全文:
Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (8) must be equal to the number of rows contained in that section before the update (8), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).错误原因:删除TableView Cell的时候没有删除对应的数据源
错误源码:
let deleteAction = UITableViewRowAction(style: .default, title: "删除", handler: {(action,indexPath) -> Void in let realm = try! Realm() self.tableView.deleteRows(at: [indexPath], with: .fade) })
修正源码:
let deleteAction = UITableViewRowAction(style: .default, title: "删除", handler: {(action,indexPath) -> Void in //移除数据源 let realm = try! Realm() try! realm.write { realm.delete(self.employees[indexPath.row]) } self.tableView.deleteRows(at: [indexPath], with: .fade) })
注意事项:数据源要根据实际情况加以删除
相关文章推荐
- ios 解决bug(2)---invalid number of rows in section 0. The number of rows contained。。。
- IOS常见bug.001—'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in
- 一个奇葩错误:Invalid update: invalid number of rows in section 0
- 一个奇葩错误:Invalid update: invalid number of rows in section 0
- Invalid update: invalid number of rows in section 0. The number of rows contained in an ....
- IOS删除tableview'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in
- 【iOS】Ambiguous reference to member 'tableView(_:numberOfRowsInSection:)'
- 删除tableview的section遇到crash:The number of rows contained in an existing section after the update
- iOS开发Implicit declaration of function 'XXXX' is invalid in C99” 报错问题
- tableView numberOfRowsInSection:(NSInteger)section;不执行
- [UIView numberofRowsInSection]unrecognized selector sent to instance 0x1808bef0 错误
- uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of ro
- cellForRowAtIndexPath not called but numberOfRowsInSection called
- iOS开发bug消灭之:Could not cast value of type 'UINavigationController' to 'RedShirt.AddEmployeeTableVi...
- 巧用 numberOfRowsInSection 处理问题
- 【内存管理-问题实例】为什么执行了numberOfRowsInSection方法后,dataArray的retainCount就少了一个? 谁把它 release了?
- Update large number of rows in a table [ID 268395.1]
- iOS开发bug消灭之:Your application has presented a UIAlertController of style ...
- [YFHomeViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x79
- 即时通讯(环信)-bug Implicit declaration of function 'NSEaseLocalizedString' is invalid in C99