By default the back button uses as a text on it a title of a viewcontroller. Can I change text on the back button without changing a title of a view controller? I need this
Try
self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil] autorelease];
I found that by looking at the backBarButtonItem docs in Apple's docs for UINavigationItem.
Marc W's approach worked great once I figured out which controller to apply it to: the one being re-titled, not the one on top. So if this is the navigation stack:
(bottom) ControllerA -> ControllerB (top)
...and you want to give a shorter title for ControllerA in the back-button displayed when ControllerB is on top, you apply the property change to ControllerA.
So it's more in the context of self.title
, not like the other left/right-bar-button setters.
If you are using storyboard:
That is it, enjoy...
[self.navigationItem setBackBarButtonItem:[[UIBarButtonItem alloc]
initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:nil action:nil]];
This worked for me.
[self.navigationController.navigationBar.backItem setTitle:@"back"];
It works for me. You can replace "back" with something else.
This one worked for me if you don't want to have a title!
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@" " style:UIBarButtonItemStylePlain target:nil action:nil];