标签栏+导航栏

时间:2009-08-23 17:18:18

标签: iphone objective-c navigation tabs

我有一个两个标签栏,在第一个标签中,我可以向下钻取三个以上...但在第二个标签中我无法向下钻取多个..有任何想法吗?

代码: 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];

该怎么办?有什么帮助吗?

3 个答案:

答案 0 :(得分:3)

我不了解您的代码结构,但通常以下列方式解决该问题:

- (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];

   ...
}

答案 1 :(得分:1)

请参阅此处给出的答案。那里还提供了一个教程链接。祝你好运。

How to : Navigation Controller in Tab Bar Controller

答案 2 :(得分:0)

您的第二个代码段是什么文件?可能是self.navigationController没有引用您认为的导航控制器。