1

Having a issue with navigationItem backBarButtonItem title on a embedded UIViewController. Im embedding UIViewControllers in scrollview for pagination, and i want to change the back button title for localization when i push something on the stack of scrollview / pagination controller.

This is the code im trying to do in didSelectRowAtIndexPath:

QueryItemTableViewController *itemView = [self.app.storyboard instantiateViewControllerWithIdentifier:@"QueryItemView"];

self.scrollcontroller.navigationItem.backBarButtonItem.title = @"Test";
[self.scrollcontroller.navigationController pushViewController:itemView animated:YES];

The view QueryItemTableViewController is correctly pushed to the navigationcontroller but the title of the back button is still the title from the previous view.

Any suggestions?

Qantas 94 Heavy
  • 15,750
  • 31
  • 68
  • 83
  • Is the requirement to display a custom title? You can do so by adding a custom UIButton and placing in leftBarButtonItem in ViewDidLoad method of the UIViewController which will be displayed. – user2071152 May 07 '14 at 10:31
  • @yourwish: Please note that inline code spans should not be used for emphasis. See http://meta.stackexchange.com/questions/135112/inline-code-spans-should-not-be-used-for-emphasis-right for more information. – Qantas 94 Heavy May 07 '14 at 11:07
  • 1
    @JoDev: hmm, weird. No worries. – Qantas 94 Heavy May 07 '14 at 13:59
  • @user2071152 that doesnt solve the problem, because its not a backbutton and then i need to do the code for clicking as well :( – Henrik B Hansen May 09 '14 at 08:06

3 Answers3

0

Could you please update the title in ViewDidLoad method of the UIViewController which is being pushed.

user2071152
  • 1,161
  • 1
  • 11
  • 25
0

Set the navigation title in the first one.. As you push to the next view controller. The back button gets set automatically, with the title you have set for the previous. Now update the Title of the present view controller in the ViewDidLoad .

So simply these are the steps:

Step 1 always set the title for the current view controller in ViewDidLoad to keep uniformity.

step 2 push to the next UIViewController. Everything gets set automatically.

N.B: You wont get any back button for the first view controller (since it is the root view controller). If you need a back button type button there, simply customise a UIBarButtonItem and use it.

Maniac One
  • 589
  • 4
  • 23
0

The title of the back button will automatically adjust for localization based on the user’s device language settings.