Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 all of them can be movable.

My problem

I do not understand how to realize this through the iOS SDK. Using a combination of tableView:canMoveRowAtIndexPath: and tableView:canEditRowAtIndexPath: I am only able to set a cell as deletable, and eventually movable, but not vice versa. I would like to set a cell as movable but not necessarily deletable. Is this possible?

like image 518
marzapower Avatar asked May 24 '11 20:05

marzapower


1 Answers

Movable:

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

Non-Deletable:

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath 
{
    return UITableViewCellEditingStyleNone;
}
like image 75
WrightsCS Avatar answered Nov 08 '22 07:11

WrightsCS