UITableView editable (rearrangeable) without cells beeing deletable

前端 未结 2 400
孤街浪徒
孤街浪徒 2021-01-06 03:24

I was wondering if there is a way to make a UITableView editable in a way where the user is able to rearrange (move) individual TableViewCells, BUT without the \"Remove-Cell

2条回答
  •  星月不相逢
    2021-01-06 03:51

    You change the if condition based on your requirement

    - (UITableViewCellEditingStyle)tableView:(UITableView *)aTableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
    {
          // in below if your write your condition on which delete is enable or disable
     if ([[friednListArr objectAtIndex:indexPath.row][@"id"] isEqualToString:user.userId]) {
        return UITableViewCellEditingStyleNone;
    }
     else{
         return UITableViewCellEditingStyleDelete;
         }
    }
    

提交回复
热议问题