【问题标题】:Add Navigation Bar in Tabbar Application [duplicate]在标签栏应用程序中添加导航栏 [重复]
【发布时间】:2012-08-13 18:51:09
【问题描述】:

可能重复:
Tab Bar Application With Navigation Controller

我的 Xcode 版本是 4.3.2。我想在基于标签栏的应用程序中添加导航栏。

谢谢

【问题讨论】:

  • UINavigationBar *bar; bar.topItem.title = @"第一个";
  • self.navigationController.navigationItem.title = @"First";但两者都不起作用。
  • 我的银行号码是 XXXCCCYYYZZZ,我想在里面加一百万美元。谢谢。
  • 我很抱歉对 Rocks 的评论,但当我看到这个问题时,我真的想到了这个:D

标签: iphone objective-c ios ios-simulator


【解决方案1】:

例如,您可以使用故事板来制作。

【讨论】:

    【解决方案2】:

    在您的 applicationDidFinishLaunching 方法中,您可以看到类似

    FirstViewController *firstViewController = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
    .
    .
    .   
    
    self.tabBarController = [[UITabBarController alloc] init];
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:firstViewController, secondViewController, nil];
    

    FirstViewController的对象添加到UINavigationController对象如下

    UINavigationController *firstNavController = [[UINavigationController alloc] initWithRootViewController:firstViewController];
    .
    .
    .
    //And in the tabbarController array add the navigationController Object instaed if FirstViewControllerObject
     self.tabBarController.viewControllers = [NSArray arrayWithObjects:firstNavController, secondViewController, nil];
    

    它完成了。现在您的FirstViewController 将被视为navigationController 并且将具有导航栏。

    编辑

    如果您只想要导航栏,那么您可以从xib 插入它或将UINavigationBar 添加为self.view 中的子视图

    【讨论】:

    • 非常感谢 S P Varma。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-14
    • 1970-01-01
    相关资源
    最近更新 更多