How to set the text of a back button on a UINavigationBar?
How do I change the title of the “back” button on a Navigation Bar
I have a UIViewController that is governed by a navigation controller. I am able to set the title of the navigation bar covering the UIViewController by simply calling
self.title = @"title". But, I want to be able to set the back button text of the navigation bar, too (for different languages n’ such..)
I don’t know how to set the back button’s text.
How do I set the back button of the UINavigation bar (programmatically not in IB)?
- Sorting NSDictionary from JSON for UITableView
- How to add seperate iPad and iPhone images in spritebuilder- Cocos2d 3.2
- How to add “Other Linker Flags” to xcode project using command line?
- iOS : Date format - 20-Sep-2012
- How to use Git properly with XCode?
- Setting AVMutableComposition's frameDuration
2 Solutions Collect From Internet About “How to set the text of a back button on a UINavigationBar?”
The setTitle way – though may seem to work, is incorrect. If you pay attention closely, you will notice that the navigation item changes to the new title while the new view is animated into view via pushViewController. The fact that you have to restore your title in viewWillAppear is kludgy, which further suggests its hack nature.
The correct way is to do the following before your pushViewController:
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle: @"Back Button Text" style: UIBarButtonItemStyleBordered target: nil action: nil]; [self.navigationItem setBackBarButtonItem: backButton]; [backButton release];
The best and easiest way according to apple documentation to set the view controller’s title to what the back should say is this –
viewController1 is under
viewController2 (and the
back button on
viewController2 is going to
viewController1.title = @"something awesome";
back button on
viewController2 will show “something awesome”
- Silent iOS Push Notification with React Native when app is in background
- Integrate iAd pre-roll video integration in my app?
- Framework not found Xcode
- XCode Interface Builder is showing “No selection” for all files
- Displaying different app name in App Store and on home screen
- Changing color of button text and state
- How to send google maps location info through SMS as a link
- How do I size a UITextView to its content?
- Xcode 7: linker command failed with exit code 1 (use -v to see invocation) again
- Xcode 9 – High CPU usage – Fan max speed
- Error building 32-bit OS X app?
- Storing arbitrary metadata with a plain-text file
- Why can't gcc or clang properly @encode SIMD vector types?
- Is it possible to use Swift's Enum in Obj-C?