Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-30-2008, 03:04 PM   #1 (permalink)
New Member
 
Join Date: Jul 2008
Posts: 93
Default 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?
mellomike is offline   Reply With Quote
Old 07-30-2008, 04:00 PM   #2 (permalink)
New Member
 
Join Date: Apr 2008
Posts: 26
Default

In your main view init:

UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil];
self.navigationItem.backBarButtonItem = backButton;
[backButton release];
iPhoneGuy is offline   Reply With Quote
Old 07-30-2008, 05:54 PM   #3 (permalink)
New Member
 
Join Date: Jul 2008
Posts: 93
Default

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.
mellomike is offline   Reply With Quote
Old 07-31-2008, 09:37 AM   #4 (permalink)
New Member
 
Join Date: Jul 2008
Posts: 93
Default

anyone have a solution for this?
mellomike is offline   Reply With Quote
Old 07-31-2008, 10:53 AM   #5 (permalink)
New Member
 
Join Date: Jul 2008
Posts: 93
Default

Quote:
Originally Posted by iPhoneGuy View Post
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
mellomike is offline   Reply With Quote
Old 07-31-2008, 12:45 PM   #6 (permalink)
New Member
 
Join Date: Jul 2008
Posts: 1
Default

Quote:
Originally Posted by iPhoneGuy View Post
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";
Kyle is offline   Reply With Quote
Old 10-27-2008, 09:59 PM   #7 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 204
Default

I know this is a little late, but...

Quote:
Originally Posted by mellomike View Post
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.
peejavery is offline   Reply With Quote
Old 10-28-2008, 02:09 AM   #8 (permalink)
Physician developer
 
StatCoder's Avatar
 
Join Date: Aug 2008
Location: Austin, TX
Posts: 221
Default

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.
StatCoder is offline   Reply With Quote
Old 10-28-2008, 09:10 AM   #9 (permalink)
Mobile Geek
 
Join Date: Aug 2008
Location: Florida, USA
Posts: 365
Send a message via AIM to rames44 Send a message via Yahoo to rames44
Default

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.
rames44 is offline   Reply With Quote
Old 10-28-2008, 12:31 PM   #10 (permalink)
New Member
 
Join Date: Sep 2008
Posts: 1,431
Default

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.
PhoneyDeveloper is offline   Reply With Quote
Old 10-28-2008, 04:34 PM   #11 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 204
Default

I solved my problem with the same solution from another thread.

http://www.iphonedevsdk.com/forum/ip...-question.html
peejavery is offline   Reply With Quote
Old 08-01-2010, 08:44 PM   #12 (permalink)
Registered Member
 
krye's Avatar
 
Join Date: Jan 2009
Location: NY, USA
Posts: 356
Default

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
krye is offline   Reply With Quote
Old 12-30-2010, 02:17 PM   #13 (permalink)
What?
 
Join Date: Nov 2010
Posts: 5
Default

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.
Poatface is offline   Reply With Quote
Old 04-11-2011, 01:08 PM   #14 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 6
Default

Code:
    [self.navigationItem setTitle:@"Study List"];
    [self.navigationController pushViewController:Viewer animated:YES];
This worked for me..
Critter is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» 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
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:47 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0