gpt4 book ai didi

ios - UITableView 删除行,commitEditingStyle 方法不触发?

转载 作者:行者123 更新时间:2023-11-29 13:51:26 28 4
gpt4 key购买 nike

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

最佳答案

我刚刚一起运行了这个:

editingStyleforRowAtIndexPath

应该是,

editingStyle forRowAtIndexPath

关于ios - UITableView 删除行,commitEditingStyle 方法不触发?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1117184/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com