Navigationbar title and back button name are same? Navigationbar title and back button name are same? xcode xcode

Navigationbar title and back button name are same?


According to UINavigationItem Class Reference

"When this navigation item is immediately below the top item in the stack, the navigation controller derives the back button for the navigation bar from this navigation item. [...] If you want to specify a custom image or title for the back button, you can assign a custom bar button item (with your custom title or image) to this property instead."

So try this in your first VC from where you are pushing other VC

self.navigationItem.title=@"Recent Books";UIBarButtonItem *backButton = [[UIBarButtonItem alloc]                                   initWithTitle:@"Back"                                   style:UIBarButtonItemStylePlain                                   target:nil                                   action:nil];self.navigationItem.backBarButtonItem=backButton;


Let's say you are pushing your viewcontroller A -> B

In viewcontroller A try adding this code in viewDidLoad method

UIBarButtonItem *btn_Back = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil];self.navigationItem.backBarButtonItem=btn_Back;

So you will see your "Back" button in viewcontroller B


The following should solve your problem

-(void)viewDidAppear:(BOOL)animated{    self.navigationController.navigationBar.backItem.title = @"back";}

You can also use this Objective-C syntax

[[self.navigationController.navigationBar backItem] setTitle:@"back"];