0

i'm having 3 screens set title to screen1 using

- (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.title =@"Products"; }

when navigation to next screen (screen2) second screen having the title "Categories" but there is a button on the top name "Products" to Screen1

i want to change the button name as "Back"

Please tell me how?

triedself.navigationItem.leftBarButtonItem .title = @"Back";

Nadhas
  • 5,421
  • 2
  • 28
  • 42
  • possible duplicate of [How to set the text of a back button on a UINavigationBar?](http://stackoverflow.com/questions/2197698/how-to-set-the-text-of-a-back-button-on-a-uinavigationbar) – Jason Coco Nov 26 '10 at 06:37

3 Answers3

0

See these two:

How to set the text of a back button on a UINavigationBar?

How do I change the title of the "back" button on a Navigation Bar

Solves your problem.

Community
  • 1
  • 1
Bourne
  • 10,094
  • 5
  • 24
  • 51
0

UIBarButtonItem *item=self.navigationItem.leftBarButtonItem; item=[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:nil action:nil]; self.navigationItem.backBarButtonItem=item; [item release];

Put this code in your first scree viewDidLoad method as it is It really works.

Ishu
  • 12,797
  • 5
  • 35
  • 51
0

You have to do something like the follows to set the text of the back bar button to something other than what the previous view was named:

UIBarButtonItem *barButton = [[UIBarButtonItem alloc] init];
barButton.title = @"Your Custom Title";

self.navigationItem.backBarButtonItem = barButton; 

You CANNOT do the following:

self.navigationItem.backBarButtonItem.title = @"Your Title";

This sets the previous view on the stack to "Your Title" and not was it was before.

Matt
  • 1,265
  • 1
  • 16
  • 24