0
私は前にを通じて段階ました...私は何もデータをtheresを言っていない行を表示するためにいくつかのコードを追加しました...Obj-C、UITableViewに `no rows found 'と表示され、すべての行が削除されてエラーが表示されるのはどうですか?
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
NSInteger num = [self.transactionsArray count];
if (num == 0) {
num = 1;
[dataTableView setEditing: FALSE animated: NO];
}
return num;
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell1;
if(transactionsArray.count == 0) {
self.navigationItem.leftBarButtonItem.enabled = FALSE;
cell1 = [[[UITableViewCell alloc] initWithStyle:
UITableViewCellStyleDefault reuseIdentifier:nil] autorelease];
cell1.textLabel.text = @"No transactons found";
return cell1;
}
//Normal processing
を
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 (1) must be equal to
the number of rows contained in that section before the update (1), plus or
minus the number of rows inserted or deleted from that section
(0 inserted, 1 deleted).
を次のエラーを取得していますエラーが発生し、numberOfRowsInSection
が完了した後に発生します。だから、そのセクションがそれを期待していなかったことを発見しました。
どうすれば対処できますか?
EDIT:ちょうどエラー
tableView:commitEditingStyle:forRowAtIndexPath:] [Line 630] commitEditingStyle start
tableView:commitEditingStyle:forRowAtIndexPath:] [Line 633] Delete now!
numberOfSectionsInTableView:] [Line 447] numberOfSectionsInTableView start
numberOfSectionsInTableView:] [Line 447] numberOfSectionsInTableView start
tableView:numberOfRowsInSection:] [Line 456] numberOfRowsInSection start
deleteRowsAtIndexPathsの後に何もできません。エラーが発生したばかりです – Jules
私の編集を参照して、削除を実行してから挿入を実行し、他のイベントを実行します。 – Jules
' - [UITableView beginUpdates]'と ' - [UITableView endUpdates]'で呼び出しをラップする必要があります。 –