07-30-2008, 02: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, 03: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, 04: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, 08:37 AM
#4 (permalink )
New Member
Join Date: Jul 2008
Posts: 93
anyone have a solution for this?
07-31-2008, 09: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, 11:45 AM
#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, 08:59 PM
#7 (permalink )
Registered Member
Join Date: Aug 2008
Posts: 167
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 09:29 PM .
10-28-2008, 01:09 AM
#8 (permalink )
Physician developer
Join Date: Aug 2008
Location: Austin, TX
Posts: 216
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, 08:10 AM
#9 (permalink )
Mobile Geek
Join Date: Aug 2008
Location: Florida, USA
Posts: 355
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, 11:31 AM
#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, 07:44 PM
#12 (permalink )
Registered Member
Join Date: Jan 2009
Location: NY, USA
Posts: 280
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
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: 650
53 members and 597 guests
alksys7 , amatoria , anonymous@ , Balillas , BillSmith , bob8caldwell , BobK , brentmc79 , ChristianK , CHV , crunkstar , darrentousignant , david77 , dcinqc , deepdelver , desk110 , e.desk , e.dsk100 , e.dsk112 , edesk01 , Emeric , ftwhere , garyshaf , gtyt38 , h2h , HookieTookie , ignicolist , iGuessSo , JamesCahall , JasonR , jbro , Jeremy1026 , jessk2herb , Kryckter , listingboat , lukasluk , MarkC , masc2279 , MiniRobinho , moehac , mofu , nobre84 , raheel , ryanduff , shebinc , Speed , strick242 , sunny dee , virvalid , Ziggy
Most users ever online was 965, 06-30-2010 at 04:26 AM.
» Stats
Members: 51,375
Threads: 52,830
Posts: 225,478
Top Poster: BrianSlick (3,576)
Welcome to our newest member, darrentousignant