iOS >> UINavigation Item Back Button Title Doesn't Change

Ohad Regev picture Ohad Regev · Aug 26, 2013 · Viewed 21.5k times · Source

I'm trying to set the BACK button for a pushed VC set within a UINavigationController stack. I use the following code, and it's not working - I still get the previous VC name appearing as the back button title.

-(void)viewWillAppear:(BOOL)animated {

    [super viewWillAppear:animated];

    self.title = @"VC Title";

    UIBarButtonItem* myBackButton = [[UIBarButtonItem alloc]
                                     initWithTitle:@"Back"
                                     style:UIBarButtonItemStyleBordered
                                     target:nil
                                     action:nil];

    self.navigationItem.backBarButtonItem = myBackButton;

}

Anyone?

Answer

Michal Gumny picture Michal Gumny · Nov 7, 2013

in parent view controller:

- (void)viewWillDisappear:(BOOL)animated
{
    self.title = @"Back";
}

- (void)viewWillAppear:(BOOL)animated
{
    self.title = @"Title of your navigation bar";
}

Will do the trick