I just inserted a table into a normal UIViewController and connected the delegate and source components with the file\'s owner. Everything works fine when i insert data into
I could just solve the problem for deleting the rows. To make it work i inserted like 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/caneditrowatindexpath
But i still have just one problem. If somebody enters in editing mode, and won't delete a row, there is no possibility, to turn the editing mode off again. If you switch the view and come back again it autmatically stops, but otherwise its not possible because i don't have a NavigationController inserted.
Is there a way, to access the state of the Deletion Control on the left of the row while editing? it would be useful to detect if somebody turned the deletion off again to jump out of editing mode.
It might not fit the apple user guide, but im just on my first project and it should just work.