I would like to change the title of the back button of the navigation bar, change from "
I tried the following but did not succeed
self.navigationController?.navigationItem.backBarButtonItem?.title = "Voltar"
I would like to change the title of the back button of the navigation bar, change from "
I tried the following but did not succeed
self.navigationController?.navigationItem.backBarButtonItem?.title = "Voltar"
You will probably need to create an object of UIBarButtonItem
.
Try this:
Swift:
let backButton = UIBarButtonItem(title: "< Back", style: UIBarButtonItemStyle.Plain, target: self, action: "goBack")
navigationItem.leftBarButtonItem = backButton
Objective C:
UIBarButtonItem *barBtnItem = [[UIBarButtonItem alloc]initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(pop)];
self.navigationItem.backBarButtonItem = barBtnItem;
[barBtnItem release];
Another way you can try is that because the back button belongs to the previous ViewController, you can try to modify it before pushing.
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
let backItem = UIBarButtonItem()
backItem.title = "Something Else"
navigationItem.backBarButtonItem = backItem // This will show in the next view controller being pushed
}
Why do this in all Views if you can do it once?
To do this, just change the project settings:
After that, just check that your device / emulator is configured in the Portuguese language.