seguedestination
seguedestination

Reputation: 419

self.navigationItem.backBarButtonItem.title=@"back" does not work for the next view controller?

I know self.navigationItem.backBarButtonItem.title is set for the next view controller;

In view Controller A: when I use

self.navigationItem.backBarButtonItem.title=@"back";

it does not work. However when

UIBarButtonItem *newBackButton=[[UIBarButtonItem alloc] initWithTitle:@"back" style:UIBarButtonItemStyleDone target:nil action:nil];
[[self navigationItem] setBackBarButtonItem:newBackButton];

it works successfully! Why…..

Upvotes: 0

Views: 1345

Answers (1)

iAnurag
iAnurag

Reputation: 9346

The title of the back button is either:

  1. The title of the previous view controller The name of the previous
  2. view controller's navigation item back button

If you are setting the back button for the current view controller's navigation item you are not setting the button that get's displayed in the current view. You are in fact setting the back button that will be used if you push another view controller from it.

Upvotes: 1

Related Questions