【问题标题】:UITableView deleting rows, commitEditingStyle method not firing?UITableView 删除行,commitEditingStyle 方法没有触发?
【发布时间】:2023-03-29 23:50:02
【问题描述】:

我有一个 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];
}

【问题讨论】:

    标签: ios cocoa-touch uitableview


    【解决方案1】:

    我只是一起运行了这个:

    editingStyleforRowAtIndexPath
    

    应该是这样的

    editingStyle forRowAtIndexPath
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-09
      相关资源
      最近更新 更多