UITableView删除行,commitEditingStyle方法没有触发?

时间:2009-07-12 23:21:17

标签: ios cocoa-touch uitableview

我有一个tableView,我想允许编辑和删除行。我让它进入编辑模式很好。但是,当我按下删除按钮时,它不会触发事件以使其删除该行?

这是我的代码:

- (IBAction)editTable:(id)sender {

    if(self.editing) {
        [super setEditing:NO animated:NO];
        [self.tableView setEditing:NO animated:NO];
        [self.tableView  reloadData];
        [self.navigationItem.rightBarButtonItem setTitle:@"Edit"];
        [self.navigationItem.rightBarButtonItem setStyle:UIBarButtonItemStylePlain];
    } else {
        [super setEditing:YES animated:YES];
        [self.tableView  setEditing:YES animated:YES];
        [self.tableView  reloadData];
        [self.navigationItem.rightBarButtonItem setTitle:@"Done"];
        [self.navigationItem.rightBarButtonItem setStyle:UIBarButtonItemStyleDone];
    }
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyleforRowAtIndexPath:(NSIndexPath *)indexPath {

    NSLog(@"HIT THIS BABY");
    NSUInteger row = [indexPath row];
    [accountsArray removeObjectAtIndex:row];
    [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}

1 个答案:

答案 0 :(得分:1)

我一起跑了这个:

editingStyleforRowAtIndexPath

应该是,

editingStyle forRowAtIndexPath