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:

backItem.rightBarButtonItem.style= 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 68030
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 offline   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

Similar Threads
thread Thread Starter Forum Replies Last Post
Mysterious menu bar item ghost app? Jantelagen OS X Mavericks (10.9) 3 Feb 24, 2014 06:41 AM
Menu bar item still appears after uninstallation of App Divegent OS X Mavericks (10.9) 2 Dec 18, 2013 09:52 AM
Changing Media Type does not move item to podcast section cgm707 iPod touch 0 Apr 30, 2013 10:39 AM
MacBook Air Menu Bar Missing Item scruffy75 Mac OS X 10.7 Lion 0 Mar 12, 2013 03:36 PM
Why this way to set the tab bar item badge doesn't work? pan17 iPhone/iPad Programming 10 Jul 22, 2012 10:06 PM

Forum Jump

All times are GMT -5. The time now is 07:07 AM.

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

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2015, MacRumors.com, LLC