设置删除某一行cell

//点击的方法

- (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;

    

}

 

posted on 2016-10-08 10:43  敏言慎行  阅读(258)  评论(0编辑  收藏  举报

导航