0

アプリケーションが写真をサーバーにアップロードします。

ユーザーがアップロードする写真を選択すると、写真の情報がコア データに保存されます。を使用して写真のリストを表示するテーブルビューが作成されfetchedResultsControllerます。

テーブルビューには、進行中のアップロード、キュー内の写真、完了したアップロードのセクションがあり、ステータスに応じて更新されます。

しかし、アップロード用に別の写真セットを追加しようとすると、前のセットがまだアップロードされている間にもう一度選択すると、次のエラーが表示されます。

この後、テーブルビューは空白になります。テーブルビューに何も表示されません。

CoreData: error: Serious application error.  An exception was caught from the delegate of NSFetchedResultsController during a call to -controllerDidChangeContent:.  Invalid update: invalid number of rows in section 1.  The number of rows contained in an existing section after the update (96) must be equal to the number of rows contained in that section before the update (62), plus or minus the number of rows inserted or deleted from that section (21 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out). with userInfo (null)
4

1 に答える 1

1

ここで起こっていることは、最初の更新で 21 個のセルが挿入され、モデルに追加されたことです。テーブル ビューは、tableView:numberOfRowsInSection: を呼び出して内部モデルを更新します。これは 83 (62 + 21) を返すはずですが、2 回目の更新でモデルに項目が追加されたため、実際には 96 が返されます。

これは通常、メイン スレッドの外部で UIKit 操作を呼び出している (非常に悪い) か、同じ関数でテーブルビューを更新せずにモデルを変更したために発生します。

于 2013-04-26T12:58:36.567 に答える