Tab Bar without Tab Bar Controller?

Discussion in 'iPhone/iPad Programming' started by Buckeyes1995, Mar 30, 2011.

  1. macrumors member

    Joined:
    Mar 4, 2011
    #1
    This is probably a stupid question.. and maybe I'm not looking at this the right way.. but here goes.

    The app that I'm working on is structured as follows (not to scale obviously):

    --------------------------------------
    | Title Label |
    --------------------------------------
    | |
    | |
    | Work Space View |
    | |
    | |
    | |
    ---------------------------------------
    | |
    | Tool Kit View |
    | |
    | |
    ---------------------------------------
    | |
    | Tab Bar (3 buttons) |
    ---------------------------------------


    The Label and Tool Kit views are all static. I used a Tab Bar element (NOT a Tab Bar Controller) from IB. All I want to do is change the Work Space View to another view to another view when the various buttons on the Tab Bar are pressed. Seems easy.. but I cannot figure out in IB how to hook up the IB Actions.. it appears the elements on the Tab Bar (buttons) can't be hooked up to IB Actions? Do I have to do this all programatically?

    Do I NEED to use a Tab Bar Controller? If so, what's the purpose of the Tab Bar Element? I've searched all around and can't find any examples or documentation on using a Tab Bar in IB, other than in relation to a TB Controller.

    Thanks, and sorry if this is obvious or dumb in advance :D
     
  2. macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #2
    It's not that hard to add a tabbarcontroller, and has some really neat delegate methods for switching from nibs etc.
    Why don't you just try that? :p
     
  3. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #3
    Seems to me a UIToolBar rather than a UITabBar would satisfy your needs.
     
  4. thread starter macrumors member

    Joined:
    Mar 4, 2011
    #4
    I had considered that.. I just like the Tab Bar look better.

    Just for my knowledge, what is the purpose of the IB Tab Bar element.. it would seem I could connect IBAction outlets to it to 'do things', but I can't figure out how.

    I'm not opposed to a Tab Bar Controller.. just more curious now than anything else.

    Thanks.
     
  5. macrumors 68000

    ulbador

    Joined:
    Feb 11, 2010
    #5
  6. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    From the Quick Help for UITabBar:
    That's not normally how tab bars are used. Rather, you assign it a delegate and then use the delegate method(s) to respond to events.
     
  7. thread starter macrumors member

    Joined:
    Mar 4, 2011
    #7
    I completely missed the delegate reference in the documentation. That clears it up.

    Thanks :D
     
  8. thread starter macrumors member

    Joined:
    Mar 4, 2011
    #8
    Thanks for mentioning the delegate use for the Tab Bar.

    I have it working perfectly now... but I'm still puzzled by what the 'Tab Bar' is really for (yes, I'm probably way overthinking this.. but I hate to blindly use something and not understand it).

    Everything I could find says that the Tab Bar Controller is the way you're "supposed " to implement tab bar applications. If so, why is the Tab Bar element included in IB? And when would you use it.

    I'll probably go back and use a Tab Bar Controller instead of a Tab Bar w/ delegation, but at least I learned how to use it :D
     
  9. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #9
    I'm not sure it's a cut-and-dry as you might like (as with much programming) but my understanding is that you use a UITabBarController when you want to set up custom view controllers for each tab (hence its viewControllers property). You would use UITabBar when you want the look and functionality of tab bar but don't have the above situation, say, only a single view controller. UITabBarControllers provide other advantages, such as the "More view controller" that you don't get with a simple UITabBar. Hope that helps.
     

Share This Page