How to change text on a back button How to change text on a back button ios ios

How to change text on a back button


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.


You can do it in the storyboard. Find the view controller you want to go back to (the one with the long title), select it's Navigation Item, and open the Attributes Inspector (Alt+Cmd+4), insert the custom Back Button title.

enter image description here