views:

105

answers:

1

Does anybody know how to disable the 'slide-to-delete' in a uitableview?

I still want to be able to delete the rows while the table is in editing mode.

Thanks

+1  A: 

First, to confirm if a table cell can be deleted simply reply to canEditRowAtIndexPath.

-(void)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
  // Return YES or NO
  return(YES);
  }
}

Then, to actually delete the table cell reply to commitEditingStyle.

-(void)tableView:(UITableView *)tv commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
  if (editingStyle == UITableViewCellEditingStyleDelete) {
  // Delete your data

  // Delete the table cell
  [self.tableView deleteRowAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
  }
}

Good luck Mats Stijlaart!

rjobidon
How does this answer the question?
BoltClock
The first code sample let you disable swipe-to-delete. The second code sample let you delete a row when editing is active. I was sure it could help you... Regards
rjobidon