Reputation: 580
I have created an application using UINavigationController. So now when i go from one view to another, i get the title of the previous screen displayed as the back button of the new view.
Sometimes if the name of the previous screen is long, i get a longer title for the back button, instead of having the long name of the previous screen is there a way for me to only have the text BACK
?
Upvotes: 0
Views: 551
Reputation: 2292
You have to create your own button and add it to your UINavigationController.
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered
target:nil action:nil];
self.navigationItem.backBarButtonItem = backButton;
[backButton release];
But remember to do it not in the viewController where your back button appears, but in the viewController where you go back after tapping your back button.
Upvotes: 2
Reputation: 2682
Yes. On the previous screen, you can create a bar button item for the back button.
Simply create a UIBarButtonItem with a nil target and a nil selector, but with the title "Back", then in your previous screen, use the self.navigationItem.backBarButtonItem
property and set that as your UIBarButtonItem.
Upvotes: 2