Reputation: 6686
My controller inherits from UITableViewController with the left button assigned to 'editButtonItem'. How can I find out when the user has tapped the "Done" button after issuing all of the deletes they want?
self.navigationItem.leftBarButtonItem = self.editButtonItem;
I'm implementing
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
With this, I see when the deletes occur for each item in the table but I would also like to know when the "Done" button is hit.
Upvotes: 2
Views: 2782
Reputation: 38664
You may also use a customized UIBarButtonItem as Edit:
editButton = [[UIBarButtonItem alloc] initWithTitle:@"Edit"
style:UIBarButtonItemStyleBordered target:self action:@selector(toggleEditing)];
editButton.possibleTitles = [NSSet setWithObjects:@"Edit", @"Save", nil];
self.navigationItem.leftBarButtonItem = editButton;
isEdit = YES; // class level flag
- (void)toggleEditing {
if (isEdit) {
isEdit = NO;
editButton.text = @"Save";
...
}
else {
isEdit = YES;
editButton.text = @"Save";
...
}
}
In this way, you have control of the caption of Edit button and change it to "Save" instead "Done" if you have a Cancel button on the right.
Upvotes: 0
Reputation: 6686
Turns out that I need to override:
- (void)setEditing:(BOOL)editing animated:(BOOL)animated
This will tell me when editing has ended.
Upvotes: 3