Customize back bar button item title

When developing navigation controller-based apps, it’s pretty common to want to customize the title of the back button that is displayed on the navigation bar. Usually the button title is set to the parent view controller’s title, but you can customize that.

All you need to do is add some code to the viewDidLoad method in the parent view controller:

– (void) viewDidLoad
{
    [super viewDidLoad];

    self.title = @”Title goes here”;
 
    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@”Back”
                            style:UIBarButtonItemStyleBordered
                            target:nil
                            action:nil];

    self.navigationItem.backBarButtonItem = backButton;   // Affect child view controller’s back button.
    [backButton release];
 }

Blogged with the Flock Browser
Advertisements

4 Responses to “Customize back bar button item title”

  1. Harry Says:

    Hey like the site, just started doing some iPhone dev and I was trying to update a form input (inside a UIWebView) using a UIButton do you know if this is even possible?

  2. 2010 in review « TEchnical SOlutions Says:

    […] Customize back bar button item title October 2009 2 comments Posted in Uncategorized. Leave a Comment » LikeBe the first to like this post. […]

  3. jeff spicer Says:

    This is the best soft solution side. we need to discus for every problem.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: