Change back button title on Navigation Controller

I was getting a bit frustrated when pushing a new View within a Navigation Controller, as by default the back button title on a new View is always the title from the preceding View;

however i want the View I’m pushing onto the stack to have consistency in the title but with the back button stating exactly that ‘ Back’.

After some digging around i finally cracked it by using this bit of code on the initialisation step of the calling View.

UIBarButtonItem *temporaryBarButtonItem = [[ UIBarButtonItem alloc] init];

temporaryBarButtonItem.title = "Back";

self.navigationItem.backBarButtonItem = temporaryBarButtonItem;

[temporaryBarButtonItem release];

By creating a custom navigation bar button on the preceding View Controller, the newly pushed View shows correctly

Share and Enjoy:
  • Facebook
  • Digg
  • StumbleUpon
  • del.icio.us
  • Yahoo! Buzz
  • Google Bookmarks
  • Posterous
  • Tumblr

No related posts.