2

我只是尝试UITableView使用以下代码从 a 中删除一行:

- (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删除前低一。

于 2010-02-09T14:23:03.563 回答