2

UITableView次のコードを使用して、から行を削除しようとするだけです。

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
     if (editingStyle == UITableViewCellEditingStyleDelete)
     {
         [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
     }
}

問題は、アプリがクラッシュすることです。(GDB: プログラムはシグナルを受け取りました: "EXC_BAD_INSTRUCTION"。) 理由を知っている人はいますか?

4

1 に答える 1

8

おそらく、返される数値を変更する必要があります

- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section

削除前よりindexPath.sectionも 1 つ低くなります。

于 2010-02-09T14:23:03.563 に答える