I am translating an app into Indonesian. The storyboard uses a navigation controller and push segues for all of its view. When I go to a view from the main menu the back button is translated correctly, but when i go to a view from there (two views away from the main menu) the back button says "Back". Thanks in advance for your help.
Please check in your "App"-Info.plist the setting "Localization native development region" and change your default language to "id" for Indonesian. As noted at other sites this affects the language on iOS default buttons like "Edit" or "Done".
see How to change UITabBarController More button's title?
Anyway, to change the title of the back button you have to consider that you have to address the PARENT-Controller, not the detail view controller.
Before you push the child view onto the navigation controller, maybe in the prepareForSegue-Method, do something like this:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@”Back” style:UIBarButtonItemStyleBordered target:nil action:nil];
[[self navigationItem] setBackBarButtonItem:backButton];
[backButton release];
}
If you're manually pushing to another view controller then, an example:
@IBAction func actionOpenSettings(_ sender: UIButton) {
if let settingsVC = self.storyboard?.instantiateViewController(withIdentifier: "SettingsViewControllerID") as? SettingsViewController {
self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "Back".localized(), style: .plain, target: nil, action: nil)
self.navigationController?.pushViewController(settingsVC, animated: true)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With