I have a UIViewController
and I'm navigating from my first view controller to second view controller and I want to change the name of the button shown on the navigationcontroller
for going back ....
SecondViewController *secondController = [[SecondViewController alloc]
initWithNibName:nil
bundle:NULL];
[self.navigationController pushViewController:secondController animated:YES];
now in the second viewcontroller
I want change the name of the button in the navigationController
.
You can achieve this by using
titleView
ofnavigationItem
Swift 3 Answer
• Create one extension for
UINavigationItem
as Below• In your controllers
viewDidLoad
do the followingTry Below Code :
In Swift I found solution very simple,
Suppose I'm on ViewControllerA and going to ViewControllerB, If I wants to change name of back button showing on ViewControllerB, I will do this in ViewControllerA,
That's it.
Note:- This will change title of ViewControllerA
In viewWillAppear write this
And in ViewWilldisapper write this
It works without story boards.
If you use Storyboard, there is a easy way to do this (it worked fine for me).
Source: http://pinkstone.co.uk/how-to-change-the-back-button-text-on-a-uinavigationcontroller-in-your-storyboard/