In my app I have UINavigationController with two UIViewControler's (first and second). The first view controller contain UITableView. When a cell of table is touched the second view controller is pushed. What I want is to set custom text to back button at the second view. Here is the code in second view.
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.leftBarButtonItem =
[[[UIBarButtonItem alloc] initWithTitle:@"Go back"
style:UIBarButtonItemStyleBordered
target:nil
action:nil] autorelease];
}
The problem is that the text of back button is changed but second view controller is not removed from the stack when the button is touched.
This has been already asked so many times:
The back button (self.navigationItem.backBarButtonItem) must be set instead of left button and not in the second controller, but in the first one (root).
The 'back' button applies to the controller doing the pushing. In this case, you would want to assign the custom back button in your 'first' UIViewController. When you push the second view controller, the back button will show the proper text
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With