【问题标题】:Tab bar + Navigation Bar标签栏+导航栏
【发布时间】:2009-08-23 17:18:17
【问题描述】:

我有一个两个选项卡栏,在第一个选项卡中,我可以向下钻取三个以上...但在第二个选项卡中,我不能向下钻取多个......有什么想法吗?

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

怎么办?请问有什么帮助吗?

【问题讨论】:

  • 你在什么操作环境下?这是 jQuery、WinForms、QT 吗?

标签: iphone objective-c navigation tabs


【解决方案1】:

我没看懂你的代码结构,但通常这个问题是通过以下方式解决的:

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

   ...
}

【讨论】:

    【解决方案2】:

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

    How to : Navigation Controller in Tab Bar Controller

    【讨论】:

      【解决方案3】:

      您的第二个代码 sn-p 位于哪个文件中?可能self.navigationController 没有引用您认为的导航控制器。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-06-13
        • 2018-12-23
        • 2012-02-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多