Navigation, OK. Toolbar, OK. Together, ?.

Discussion in 'iOS Programming' started by smuffle, Mar 25, 2009.

  1. smuffle macrumors newbie

    Apr 8, 2006
    I'm now 3 months into the Xcode trying with all my might to get a grip of this monster. It's been antisocial, hard, painful and unbelievably frustrating but.. kinda fun. I've been making some great progress recently but, after spending 2 whole days trying to make one simple, simple, SIMPLE thing to work, I feel like jumping up and down on my wife's Mac (I just upgraded the memory in mine).

    I have a tabbed app with 5 views up and running, each doing their own thing. I also have another app with a navigation bar that allows me to drill down into a simple database. Both work great and I *believe* I understand what's going on. Happy.

    But how on earth do I put them together? How do I put the drill down navigation app "into" one of the views in my tabbed app? It sounds simple but seeing as both of them have separate delegates I don't know where to start. I've tried to "intelligently" merge the code together so that the navigation codes sits in one of the views and the delegate holds the necessary properties/methods to keep everybody happy, but no luck. It just crashes.

    I can't really post all the code, but just knowing the following simple question would be a great start; is the following delegate code OK? Are the navigation bar and toolbar "added" here?

    - (void)applicationDidFinishLaunching:(UIApplication *)application {
    [window addSubview:[navigationController view]]; // navigation bar
    [window addSubview:rootController.view]; // toolbar
    [window makeKeyAndVisible];

    I've looked around the internet for sample code/skeleton apps to see where I'm going wrong but all the samples are an Navigation OR Toolbar examples. All help gratefully received.

  2. yayaba macrumors 6502

    Apr 24, 2007
    San Francisco Bay Area
    I'm not sure if this exactly answers your question but on my app the main app delegate has a tab bar controller that I add separate navigation controllers to. Then I set the main window view to be the tab bar controllers view.

    Your sample code looks like you're putting the nav controller on the same level as the tab controller. Maybe try putting the nav controller as a child of the tab controller?

    I don't use any delegate methods of the tab bar controller nor navigation controllers (I'm not aware they have required delegate methods?).
  3. CocoaPuffs macrumors 68010

    Aug 23, 2008
    This is actually one of the most common question, so next time before you pull out your hair, try google.

    If you are using IB, what you need to do is to have both the UINavigationController and UITabBarController outlets in your delegate, and add the UITabBarController as root view. Then once you did that, expand the UITabBarController's view controllers in the IB window, then link the controller you wish to connect the NavController to the navcontroller outlet.

Share This Page