How can I make a cell movable but not deletable in a UITableView?

前端 未结 1 1328
南笙
南笙 2021-02-19 21:11

My aim

Hello, my problem is quite simple. I have a UITableView with a couple of cells. Some of them can be deleted (but not necessarily all of them), but

1条回答
  •  醉酒成梦
    2021-02-19 21:33

    Movable:

    -(BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath         
    {
        return YES;
    }
    

    Non-Deletable:

    - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath 
    {
        return UITableViewCellEditingStyleNone;
    }
    

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