2

I have a UINavigationBar with two different screens. On both screens the NavigationBar has the same title. So the BackButton should have just Back as text instead of the NavigationBar's title.

If I set the parents ViewController title to nil I have a backButton with the text Back, which gets localized automatically by iOS.

I know I can set the text to back as described in this question: How to set the text of a back button on a UINavigationBar? However, then the Back is hardcoded and wont get translated by iOS automatically.

I don't want to maintain the localizations by myself in the Localizable.strings but rather use the predefined values from iOS.

I would like to always have a title on my NavigationBar and a backButton which says Back and gets localized automatically using the by iOS defined values.

Does somebody know if and how such an behavior could be achieved?

Community
  • 1
  • 1
pre
  • 3,475
  • 2
  • 28
  • 43

1 Answers1

2

As far as I know you cannot force that behavior. One way of getting around it would be by adding the title to the navigation bar with a, say, UITextView:

[self.navigationItem setTitleView:myUITextView]
andershqst
  • 1,454
  • 1
  • 14
  • 24
  • It would solve your issue. And doing it the way I describe is not that much of a hassle. I would make a factory method for the view you want to use for setting the titles, and then you can set the title in one line of code in your viewcontrollers. Something like [self.navigationItem setTitleView:[ViewFactory navTitleView:@"MyTitle"]] – andershqst May 17 '12 at 10:08