2

I have a two tab bar,In first tab ,i can drill down more than three... but in second tab i cannot drill down more than one.. Any ideas?

code: DemoAppdelegate.m

- (void)applicationDidFinishLaunching:(UIApplication *)application {
[window addSubview:tabBarController.view];
}

First tab controller is "FirstViewController"
in FirstViewController.m i have written to drill down to "billsummary.xib" 


DemoAppDelegate *app = (DemoAppDelegate *)[[UIApplication sharedApplication] delegate];
    UINavigationController *naviController = app.navigationController;
    BillsSummary *aViewAController = [[BillsSummary alloc] initWithNibName:@"BillsSummary" bundle:[NSBundle mainBundle]];

    [naviController pushViewController:aViewAController animated:YES];
    [aViewAController release];

which is working fine.But same code for in second tab for another .xib is not working and in second tab i have not used appdelegate instead i used "self.navigationcontroller"

UINavigationController *naviController = self.navigationController;
    PaymentsAmount *aViewAController = [[PaymentsAmount alloc] initWithNibName:@"PaymentsAmount" bundle:[NSBundle mainBundle]];

    [naviController pushViewController:aViewAController animated:YES];  
    [aViewAController release];

what to do? Any help please?

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445

3 Answers3

3

I didn't understand your code structure, but usually that problem is solved in the following way:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
   ...

   // Initialize UINavigationControllers and push first viewcontrollers for each one

   UIViewController *view1 = [[UIViewController alloc] init];
   UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:view1];
   [view1 release];

   // Same for the second NavigationController 

   ...      

   // Initialize UITabBarController
   UITabBarController tController = [[UITabBarController alloc] init];
   tController.viewControllers = [NSArray arrayWithObjects:nav1, nav2, nil];
   [nav1 release];
   [nav2 release];

   [window addSubview:tController.view];

   ...
}
defvol
  • 14,392
  • 2
  • 22
  • 32
1

Please Refer the answer given here. A tutorial link is also provided there. Best of luck.

How to : Navigation Controller in Tab Bar Controller

Community
  • 1
  • 1
sagarkothari
  • 24,520
  • 50
  • 165
  • 235
0

What file does your second code snippet live in? It might be that self.navigationController doesn't refer to the navigation controller you think it does.

Jeff Kelley
  • 19,021
  • 6
  • 70
  • 80