Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

johnmerlino

macrumors member
Original poster
Oct 22, 2011
81
0
Hey all,

I have a tab bar controller and it rotates between for view controllers. Problem is for one of controllers, I want to display a uibarbuttonitem. But right now the button wont display, as all four controllers inherit the uinavigation item of the tab bar controller.
 
That is some of the vaguest question I have ever seen :)
Try to post some code, what you did, what you try to do, what exactly goes wrong..

I'm using xcode storyboard 4.3. THe problem is I have a ui tab bar controller, with 4 tabs. I have a list view and the list view segues to the tab bar controller. Now automatically a back button displays on the ui navigation item of the tab bar controller. The problem is I tried adding a bar button item to one of the four controllers that has a relationship to the tab bar controller. I can visually see it added on the storyboard, but when I compile and run simulator, the bar button item is not there. It just has the back button to the list page for all four controllers that have a relationship to the tab bar controller.

Here's an image of what's happening:

http://i45.tinypic.com/2i13829.jpg

Notice that the storyboard shows the bar button item while the simular does not.

thanks for response
 
I'm going to guess that the Navigation bar was not one that dragged in there but one that you automatically got from linking your view to a navigation controller. You can add the button using this code:
Code:
 UIBarButtonItem *yourButton = [[UIBarButtonItem alloc]initWithTitle:NSLocalizedString(@"yourButtonName", "something") style:UIBarButtonItemStyleDone target:self action:@selector(yourActionMethod)];
self.navigationItem.rightBarButtonItem = yourButton;

Throw this into your viewDidLoad delegate.

Apples documentation is one of the best I've ever seen, you might want to give it a whirl :)
 
Last edited:
I'm going to guess that the Navigation bar was not one that dragged in there but one that you automatically got from linking your view to a navigation controller. You can add the button using this code:
Code:
 UIBarButtonItem *yourButton = [[UIBarButtonItem alloc]initWithTitle:NSLocalizedString(@"yourButtonName", "something") style:UIBarButtonItemStyleDone target:self action:@selector(yourActionMethod)];
self.navigationItem.rightBarButtonItem = yourButton;

Throw this into your viewDidLoad delegate.

Apples documentation is one of the best I've ever seen, you might want to give it a whirl :)

That is for ARC project, don't forget to do [yourButton release]; after assigning if you are in a non ARC project.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.