時,我使用的是什麼,我相信是添加項目到表格視圖一個共同的模式 -無效的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
我添加了一個縮小的演示項目,只有幾行代碼表現出相同的問題。 –