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 ,
Objective-C:
UIBarButtonItem *btnBack = [[UIBarButtonItem alloc]
initWithTitle:@"Done"
style:UIBarButtonItemStyleBordered
target:self
action:nil];
self.navigationController.navigationBar.topItem.backBarButtonItem=btnBack;
Swift:
var btn = UIBarButtonItem(title: "Done", style: .Plain, target: self, action: "backBtnClicked")
self.navigationController?.navigationBar.topItem?.backBarButtonItem=btn