因此,在我的 viewDidLoad 方法中,我调用了:
self.navigationItem.rightBarButtonItem = self.editButtonItem;
然后稍后在我的 tableView:commitEditingStyle:forRowAtIndexPath: 我这样做:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
[self.list removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
但是,当我在 tableView 中删除一行时,在实际运行应用程序时,我在对列表的 removeObjectAtIndex 调用中抛出异常。我试着把它拿出来,但后来我在 tableView deleteRowsAtIndexPaths:withRowAnimation 上抛出了另一个异常:
请帮忙!提前致谢!