时,我使用的是什么,我相信是添加项目到表格视图一个共同的模式 -无效的tableview更新旋转装置
- 主控制器创建模态控制器和自身注册为代表
- 模式视图控制器呈现
- 用户提供了一些数据和点击保存在模态的导航栏按钮
- 模态视图控制器发送其代表含有细节的消息输入
- 原始控制器接收该消息并驳回模态
- 原始控制器更新数据模型并插入一个新行到其的tableview
这是除了在一个特定方案中运作良好。
如果该设备是旋转而模式出现时,该应用程序在解散模态后崩溃。新行插入正确,但之后立即失败:
*** Assertion failure in -[UITableView _endCellAnimationsWithContext:],
/SourceCache/UIKit_Sim/UIKit-2380.17/UITableView.m:1070
2013-07-28 17:28:36.404 NoHitterAlerts[36541:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '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 (1 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'
我不能为我的数字生活为什么会发生这种情况。如果我使用所提供的模式进行旋转,那么测试用例始终会失败。我注意到,只需重新加载tableview,而不是用动画插入行就可以正常工作。
这里是一个裸露的骨头项目演示了同样的问题: demo project
- 运行在iPhone SIM
- 项目中的项目添加到列表 - 工作正常
- 回到第一个屏幕上,旋转到风景
- 再次运行相同的测试。仍然有效。
- 回到第一个屏幕,启动模态。旋转模拟器而模态仍然呈现。点击'添加项目'。崩溃。
上可能被这里发生的任何想法?
什么是您使用添加值到的tableView的代码? – Jsdodgers
我添加了一个缩小的演示项目,只有几行代码表现出相同的问题。 –