What you can do is add IBAction as a selector to your editButton. When editButton is used, this method will be called. Example:
-(void)viewDidLoad { // ... [self.editButtonItem setAction:@selector(editAction:)]; [self.navigationItem setRightBarButtonItem: self.editButtonItem]; // .. your code } -(IBAction)editAction:(id)sender { UIBarButtonItem * button = ((UIBarButtonItem*)sender); if (!self.tableView.editing) { [self.tableView setEditing:YES animated:YES]; [button setTitle:@"Done"]; // do your stuff... } else { [button setTitle:@"Edit"]; [self.tableView setEditing:NO animated:YES]; // do your stuff... } }
If you have your own UIButton and you are not using the standard self.editButtonItem, then use [yourButton addTarget: the action itself: @selector (editAction :) forControlEvents: UIControlEventTouchUpInside]; And treat it like UIButton * in editAction: method
AzaFromKaza
source share