Reputation: 447
I'm using swipe to delete for a custom cell. For one particular cell the swipe function should not work.
My custom cell displays "Add new values". When this is selected a few cells are added and when we swipe, delete option appears. What I want is that swipe function should not work for the "add new values" cell.
Upvotes: 0
Views: 223
Reputation:
You can try this:
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
switch (indexPath.row)
{
case 0: break; //assuming that your add cell is 1
default:
return UITableViewCellEditingStyleDelete; // rest of them you can delete
break;
}
}
Upvotes: 0
Reputation: 1637
Check the cell type in tableView:canEditRowAtIndexPath: , and return false if it's of the type that you can't edit.
So in pseudo code
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
NSInteger row = [indexPath row];
// Check row type
if(rowType==add_new_values_type) // YOU NEED TO WRITE THIS
{
return false;
}
// Return YES - we will be able to delete the row
return YES;
}
Upvotes: 2