07-30-2008, 03:04 PM
#1 (permalink )
New Member
Join Date: Jul 2008
Posts: 93
how to change the nav bar back button title?
I'm having a problem setting the text that's shown on the back button of a navigation bar.
I know by default the but displays the title property of the previous view controller, but how do I set the text myself?
07-30-2008, 04:00 PM
#2 (permalink )
New Member
Join Date: Apr 2008
Posts: 26
In your main view init:
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil];
self.navigationItem.backBarButtonItem = backButton;
[backButton release];
07-30-2008, 05:54 PM
#3 (permalink )
New Member
Join Date: Jul 2008
Posts: 93
hi I just put that code into my view controller's initWithNibName and it's still showing the title property of the last view controller.
07-31-2008, 09:37 AM
#4 (permalink )
New Member
Join Date: Jul 2008
Posts: 93
anyone have a solution for this?
07-31-2008, 10:53 AM
#5 (permalink )
New Member
Join Date: Jul 2008
Posts: 93
Quote:
Originally Posted by
iPhoneGuy
In your main view init:
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil];
self.navigationItem.backBarButtonItem = backButton;
[backButton release];
hey that did work!!! I was adding that code to the wrong view controller. It's supposed to go inside the calling controller, not the one currently on screen.
Thanks for your help
07-31-2008, 12:45 PM
#6 (permalink )
New Member
Join Date: Jul 2008
Posts: 1
Quote:
Originally Posted by
iPhoneGuy
In your main view init:
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil];
self.navigationItem.backBarButtonItem = backButton;
[backButton release];
Unless I´m misunderstanding something you can just use
Code:
self.navigationItem.title =@"Your Title";
10-27-2008, 09:59 PM
#7 (permalink )
Registered Member
Join Date: Aug 2008
Posts: 204
I know this is a little late, but...
Quote:
Originally Posted by
mellomike
It's supposed to go inside the calling controller, not the one currently on screen.
Is there a way to change it from the controller currently being viewed?
I tried the following, but it doesn't work.
Code:
self.navigationItem.backBarButtonItem.title = @"Test";
Last edited by peejavery; 10-27-2008 at 10:29 PM .
10-28-2008, 02:09 AM
#8 (permalink )
Physician developer
Join Date: Aug 2008
Location: Austin, TX
Posts: 221
I think the principle is that since you might call your current view from a variety of other views, the back button title needs to be determined by the previous view. Someone did mention that they created another toolbar button in the current view that laid on top of the back button and then named it and it seemed to work.
10-28-2008, 09:10 AM
#9 (permalink )
Mobile Geek
Join Date: Aug 2008
Location: Florida, USA
Posts: 365
Well, if worst comes to worst, from your top view you could grab the array of view controllers from the navigation controller, go to the one that's "one down" on the stack and fiddle with it.
Alternately, if view controller A pushes view controller B on top of itself, it could, at that point, make the change before doing the push based on which view controller was being pushed.
10-28-2008, 12:31 PM
#10 (permalink )
New Member
Join Date: Sep 2008
Posts: 1,431
Any view controller that's been pushed onto a navbar has a parentViewController. So probably a view controller could manipulate the back button title using that property.
08-01-2010, 08:44 PM
#12 (permalink )
Registered Member
Join Date: Jan 2009
Location: NY, USA
Posts: 356
Sweet. That worked for me too, the usual
Code:
UIBarButtonItem *temporaryBarButtonItem = [[UIBarButtonItem alloc] init];
temporaryBarButtonItem.title = @"Back";
self.navigationItem.backBarButtonItem = temporaryBarButtonItem;
[temporaryBarButtonItem release];
and
Code:
self.navigationItem.backBarButtonItem.title = @"Back";
didn't work
12-30-2010, 02:17 PM
#13 (permalink )
What?
Join Date: Nov 2010
Posts: 5
I also used this:
Code:
UIBarButtonItem *temporaryBarButtonItem = [[UIBarButtonItem alloc] init];
temporaryBarButtonItem.title = @"Back";
self.navigationItem.backBarButtonItem = temporaryBarButtonItem;
[temporaryBarButtonItem release];
It worked for me, however it only worked the first time. Once I had used it, using it on a later view caused that back button to have the title "<".
I have no idea what would cause this, but if anyone has any idea I'd like to know, both to touch up the look of my app and because I'm kind of curious.
04-11-2011, 01:08 PM
#14 (permalink )
Registered Member
Join Date: Jan 2011
Posts: 6
Code:
[self.navigationItem setTitle:@"Study List"];
[self.navigationController pushViewController:Viewer animated:YES];
This worked for me..
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
» Advertisements
» Online Users: 429
13 members and 416 guests
bev6a8hl , beyondstop , Edsilmars , erritikamathur , HowEver , john234ny , MozyMac , Objective Zero , phillipie99 , pill5b3rry , pochuang , pufftissue , Rudy
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 157,847
Threads: 88,913
Posts: 379,291
Top Poster: BrianSlick (7,072)
Welcome to our newest member, bev6a8hl