displaying uibarbuttonitem for one of controllers connected to tab bar controller

Discussion in 'iOS Programming' started by johnmerlino, Jun 13, 2012.

  1. johnmerlino macrumors member

    Joined:
    Oct 22, 2011
    #1
    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.
     
  2. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #2
    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..
     
  3. johnmerlino thread starter macrumors member

    Joined:
    Oct 22, 2011
    #3
    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
     
  4. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #4
    Sorry, I don't use storyboards. I cannot help you in this case, but there will be some other forum members that can ;)
     
  5. johnmerlino thread starter macrumors member

    Joined:
    Oct 22, 2011
    #5
    Ill just add a button to view
     
  6. Quboid, Jun 14, 2012
    Last edited: Jun 14, 2012

    Quboid macrumors 6502

    Joined:
    Oct 16, 2006
    Location:
    everywhere
    #6
    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 :)
     
  7. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #7
    That is for ARC project, don't forget to do [yourButton release]; after assigning if you are in a non ARC project.
     

Share This Page