views:

41

answers:

2

hi,

i have this at my appdelegate:

for 1st app:

   - (void)applicationDidFinishLaunching:(UIApplication *)application {    

   [window addSubview:rootController.view];
   [window makeKeyAndVisible];
  }

this will display a navigation and tabar display for my app.

ok no problem here.

next i have this from another app:

   - (void) applicationDidFinishLaunching:(UIApplication *)application {    
      _window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

     MainViewController *_mainViewController = [[MainViewController alloc] init];
      UINavigationController *_navigationController = [[UINavigationController alloc] initWithRootViewController:_mainViewController];

     [_window addSubview:_navigationController.view];
       [_window makeKeyAndVisible];
       }

which also works fine.

now, how can i include all this function into my 1st app? i would like to use it for one of my tab options.

i've tried:

 - (void)applicationDidFinishLaunching:(UIApplication *)application {    

    Tab4 *_mainViewController = [[Tab4 alloc] init];
    UINavigationController *_navigationController = [[UINavigationController alloc] initWithRootViewController:_mainViewController];

    [window addSubview:_navigationController.view];
[window addSubview:rootController.view];
[window makeKeyAndVisible];

}

sort of combining the two. there is no compiling error but the program is not working. i got it wrong somewhere and stuck. is it possible to have 2 subivew? any help is greatly appreciated. thks.

hi,

i've embedded the a nav controller in my tab bar. but doing this does it "replace" the code completely?

      _window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

     MainViewController *_mainViewController = [[MainViewController alloc] init];
      UINavigationController *_navigationController = [[UINavigationController alloc] initWithRootViewController:_mainViewController];

     [_window addSubview:_navigationController.view];
       [_window makeKeyAndVisible];

tab view gets load up fine but it is unable to receive a notification. thks

A: 

Any view can have 0 .. n subviews, the main window included. What are the frames of the two subviews? Maybe one is just sitting on top of the other and is therefore hidden.

Mike
+2  A: 

Your TabBarController should be the only subview to the window, and a window should have only 1 subview. Include the navigation controller inside one of the tabs. A TBC cannot be used inside of a navigationController. Here is a simple tutorial showing you how to add a navigation controller to a tab. Also, you should read the Apple Documentation on Tab Bars.

MishieMoo