//点击的方法
- (nullable NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath{
// 删除按钮
UITableViewRowAction *action1 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
[self.dataArray removeObjectAtIndex:indexPath.section - 1];
;
[tableView deleteSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone];
}];
action1.backgroundColor = [UIColor redColor];
return @[action1];
}
//设置某一行的可编辑与否
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
NSIndexPath * indexP =[NSIndexPath indexPathForRow:0 inSection:0];
if (indexP == indexPath) {
return NO;
}
return YES;
}