Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread Display Modes
Old Dec 27, 2012, 07:38 PM   #1
macrumors newbie
Join Date: Nov 2012
Changing the style of a bar button item

Let's say that I have a navigation controller and I push a view controller.By doing this, a button that leads me back to the previous controller is created.

I've found the navigation item holding the button this way:

UINavigationItem* backItem=self.navigationController.navigationBar.topItem;
If I change it's title also the button title changes.

But the only button is backItem.rightBarButtonItem, even if the button is displayed at the left, the other two buttons (back and right) are nil.

If I try changing the button item this way:

Code: UIBarButtonItemStylePlain;
The title of the button leading me back doesn't change, is that another button? How do I change the style of the button leading me back to the other view controller?
ramy1989 is offline   0 Reply With Quote
Old Jan 3, 2013, 02:03 AM   #2
macrumors newbie
Join Date: Jan 2013
Location: Tromsų, Norway
Try something like this:

UIBarButtonItem *previous = [[UIBarButtonItem alloc] 
Greetings from the Arctic Circle
polarsirkelen is offline   0 Reply With Quote
Old Jan 3, 2013, 04:40 PM   #3
macrumors 68030
MattInOz's Avatar
Join Date: Jan 2006
Location: Sydney
Is there a Reason setting.
yourViewController.navigationItem.backButtonItem = someButton;
wouldn't work for you?

If you do that to your viewControllers when you set them up, when you push the viewController on to the navigation controller the buttons will be those set for the visible viewController. You don't have to worry about reseting each time that view will appear.
There is no such thing as "Collective Wisdom"
[ iPhone 5s, iPad Mini, 13" MacBookPro 2.7Ghz, 27"Al iMac i7, Black MacBook 13"]
MattInOz is offline   0 Reply With Quote
Old Jan 7, 2013, 08:24 AM   #4
macrumors Demi-God
KoolStar's Avatar
Join Date: Oct 2006
Location: Kentucky
Send a message via AIM to KoolStar Send a message via Skype™ to KoolStar
You must change the button before you push on the new view controller.
"Innovation distinguishes between a leader and a follower." : S.J.
KoolStar is offline   0 Reply With Quote
Old Jan 7, 2013, 05:05 PM   #5
macrumors 68020
PhoneyDeveloper's Avatar
Join Date: Sep 2008
I usually set a custom left or back button in viewDidLoad of the view controller that's been pushed.
PhoneyDeveloper is online now   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

Forum Jump

All times are GMT -5. The time now is 05:08 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013,, LLC