UITableView editable (rearrangeable) without cells beeing deletable

前端 未结 2 401
孤街浪徒
孤街浪徒 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;
         }
    }
    
    0 讨论(0)
  • 2021-01-06 03:55

    Have you tried implementing the editingStyleForRowAtIndexPath method and returning UITableViewCellEditingStyleNone?

    0 讨论(0)
提交回复
热议问题