UITabBarController + UINavigationController

Discussion in 'iOS Programming' started by rendezvouscp, Sep 6, 2008.

  1. rendezvouscp macrumors 68000

    Joined:
    Aug 20, 2003
    Location:
    Long Beach, California
    #1
    Hey,

    Like most apps, the app that I’m building requires the use of a UITabBarController and UINavigationControllers together. This theoretically is pretty simple; I’ve read the docs, I understand that the UITabBarController holds the collection of UINavigationControllers, and each UINavigationController holds the UIViewControllers necessary to display views.

    In short, my current design looks like so:
    -File’s Owner
    -First Responder
    -App Delegate
    -Window
    -Tab Bar Controller
    -Tab Bar​
    -First Navigation Controller​
    -Navigation Bar​
    -View Controller​
    -Table View​
    -Navigation Item​
    -Tab Bar Item​

    Where I’m getting confused is when I try to move from a one-nib design to a multi-nib design. I *believe* that a better design would be to have a UITabBarController in a MainWindow.nib and have that nib load other nibs with the UINavigationControllers as needed.

    So, I create my new nibs, create navigation controllers in the new nibs, tell my UITabBarController Tab Bar Item to look for the nib, and find my app useless. I don’t know what I’m doing incorrectly in my move from one nib to multiple nibs.

    I’d appreciate any advice or help or guidance that anyone can provide. Thanks in advance.
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    Do you have your nibs properly using the File Owner? Are all IBOutlets hooked up? Remember to use the debugger.
     
  3. flabrie macrumors newbie

    Joined:
    Oct 11, 2008
    #3
    Did you finally found a solution for this? Because I'm trying to perform the same thing, and I can't get it to work. I would be very interested to get hints to achieve this UITabBarController + UINavigationController architecture using multiple NIBs.
     
  4. Niiro13 macrumors 68000

    Joined:
    Feb 12, 2008
    Location:
    Illinois
    #4
    Generally, you'd put the tabbar in the mainview along with the navigationcontrollers.

    Then you'd link the viewcontroller from each of the navigationcontrollers in separate files each.

    For your situation, the reason why it's not working is that you'd have to subclass the navigationcontrollers for it to work...and generally, it's not recommended to subclass the navigationcontrollers
     
  5. nummish macrumors newbie

    Joined:
    Oct 15, 2008
    #5
    When reading this, I understood it as removing the "NIB Name" property from the view of a given tab bar item, then creating a NavigationController, who's "NIB Name" is the secondary nib/xib file for the root of the navigation controller.

    If that is correct, how do you cause the NavController to be linked to the subview generated for a given TabBar entry in IB? Or is this something that must be done in code?

    ==EDIT==

    Didn't realize that each button on the tab bar *is* a viewcontroller, switched one to a navcontroller, pushed the view on at load time and problem solved.
     
  6. kev21986 macrumors newbie

    Joined:
    Apr 7, 2008
    #6
    OMG Thanks. I spent 2 days trying to figure out how to do this. The key is the navigationcontroller is in the tabbarcontroller nib.
     

Share This Page