I am using storyboards in my application, and if I set the title property of a ViewController class, that string will appear as the text of my back button when I push a SecondViewController, how can I change this?, I want to put a different title for the back button.
I have used this but it doesn't work:
UIBarButtonItem *btnBack = [[UIBarButtonItem alloc]
initWithTitle:@"Back"
style:UIBarButtonItemStyleBordered
target:self
action:nil];
[self.navigationItem setBackBarButtonItem: btnBack];
please help me
Try this:
Set a backBarButtonItem to the navigationItem of the previous viewController. Setting the topItem only works on the first time viewWillAppear. Please check this post for detail: iOS Set Navigation Bar Back Button Title
Try changing the title of the first view controller where you push the second view controller, and set the tittle to the old one when u pop.
When you use Storyboards you can change the text of the left bar button item aka the back button with no code. You will obviously need a
UINavigationController
within your Storyboard so you have the ability to push and pop views.Then when a view is pushed from this view it will use this title set.
Try this ,
Objective-C:
Swift: