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.
Mine is:
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return self.editing ;
}
First, to confirm if a table cell can be deleted simply reply to canEditRowAtIndexPath.
-(BOOL)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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With