I have a standard UINavigationController setup. One particular view displays an "Edit" button on the right side of the Navigation Bar. When that button is pressed and the view switches to editing mode I would like to replace the "Back" button on the left side with an "Add" button. Of course, when editing is finished (the user presses "Done") the button on the left side should change again to the back button.
views:
168answers:
1
A:
The obvious answer works. Assuming you have declared a UIBarButtonItem called addButton, you can implement setEditing:animated: as follows:
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
[super setEditing:editing animated:animated];
if(editing) {
self.navigationItem.leftBarButtonItem = addButton;
} else {
self.navigationItem.leftBarButtonItem = self.navigationItem.backBarButtonItem;
}
}
Tim Isganitis
2009-12-11 03:57:05