I have a bar button, let's call it button 1, which when clicked, programatically segues to a different page.
However, after clicking another button (button 2), button 1's title is changed.
From then on, button 1 no longer responds regardless of whether it's title has been changed back by clicking button 2 again.
I hope you understand, if not - I can clarify
code: (button 2 is edit) - (1 is info/add)
-(void)editButton:(id)sender
{
[self setEditing:(![self isEditing])];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Done"
style: UIBarButtonItemStylePlain
target:self
action:@selector(edit:)];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Add"
style: UIBarButtonItemStylePlain
target:self
action:@selector(infoToAdd:)];
}
-(void) edit:(UIBarButtonItem *) barBtnItem
{
// if not editing
if (![self isEditing]) {
[self setEditing:YES];
[self.navigationItem.rightBarButtonItem setTitle:@"Done"];
[self.navigationItem.leftBarButtonItem setTitle:@"Add"];
} else {
[self setEditing:NO];
[self.navigationItem.rightBarButtonItem setTitle:@"Edit"];
[self.navigationItem.leftBarButtonItem setTitle:@"Info"];
}
}
-(void) infoToAdd:(UIBarButtonItem *) barBtnItem
{
// if not editing
if (![self isEditing]) {
[self.navigationItem.leftBarButtonItem setTitle:@"Info"];
} else {
[self.navigationItem.leftBarButtonItem setTitle:@"Add"];
}
}
-(void)infoAddButton:(id)sender
{
if (self.tableView.isEditing) {
[self performSegueWithIdentifier:@"segueToAdd" sender:self];
} else {
[self performSegueWithIdentifier:@"segueToInfo" sender:self];
}
}
Edit:
It seems the function 'infoAddButton' is not even getting called (I used a breakpoint) when I press the button, after changing it's title.