I have this table on linked to a database with a “Edit” on top-right.
I can delete swiping, but if I press the Edit button nothing happen!
I mean, I wrote a similar call for another table in the same program, and when i press edit, a small “Unlock to delete” appear; then if you press it you can delete the element/row…
not here!
- (void)viewDidLoad
{
self.title = @"Categorie";
[super viewDidLoad];
self.navigationItem.rightBarButtonItem = self.editButtonItem;
[self.navigationItem setHidesBackButton:YES animated:YES];
[tableView reloadData];
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
- (void)tableView:(UITableView *)_tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
{
// A lot of code...
}
}
You need to tell the tableView to begin editing with setEditing:(BOOL)editing animated:(BOOL)animate
Here’s the a sample action method: