I could just solve the problem of deleting rows. To make it work, I inserted, as the ACB told me, the following methods:
//when blue accessory button has been pressed - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath{ //turn into edit mode [tableView setEditing:YES animated:YES]; } - (void)setEditing:(BOOL)editing animated:(BOOL)animated{ [super setEditing:editing animated:animated]; } // method to enable the deleting of rows -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{ if (editingStyle == UITableViewCellEditingStyleDelete) { Activity *activity = [allActivities objectAtIndex:indexPath.row]; // remove the item from the array [allActivities removeObjectAtIndex:indexPath.row]; //delete element from database with created method [dataController deleteFromTable:@"activity" theElementWithID:activity._id]; [tableView setEditing:NO animated:YES]; // refresh the table view [tableView reloadData]; } }
I found this solution on cocoapi.wordpress.com/tag/caneditrowrowdedexpath
But I still have one problem. If someone enters the editing mode and does not delete the line, there is no way to disable the editing mode. If you switch the view and come back again, it will automatically stop, but otherwise it is impossible, because I do not have a built-in navigation controller.
Is there any way to access the state of the delete control to the left of the line during editing? it would be helpful to detect if someone had disabled deletion again to exit edit mode.
This may not be consistent with the Apple user guide, but im is only on my first project, and it should just work.
source share