单击tabbar更多按钮时获取两个导航栏

时间:2013-11-25 06:24:17

标签: ios iphone uitabbarcontroller uinavigationbar

在整个应用程序中有一个主导航控制器,还有一个主tabbarcontroller,问题是当我点击tabbarcontroller的'more'选项卡时,它显示两个导航栏

为了解决这个问题,我尝试使用以下代码隐藏我的主导航控制器导航栏:

        self.tabbar.navigationController.navigationBarHidden =YES;

但这样做会给我带来意想不到的结果,半导航栏的形式为半黑背景。

如果有人知道解决方案,那么请帮助我。 提前谢谢。

3 个答案:

答案 0 :(得分:2)

使viewController具有单独的UINavigationController,

将此代码放在Appdelegate

ViewController *a = [[ViewController alloc] initWithNibName:@"a" bundle:nil];
ViewController *b= [[CreateMeetingViewController alloc] initWithNibName:@"b" bundle:nil];
ViewController *c = [[SettingsViewController alloc] initWithNibName:@"c" bundle:nil];


UINavigationController *nav_1 = [[UINavigationController alloc] initWithRootViewController:a];
UINavigationController *nav_2 = [[UINavigationController alloc] initWithRootViewController:b];
UINavigationController *nav_3 = [[UINavigationController alloc] initWithRootViewController:c];

MainTabBar = [[UITabBarController alloc] init];
MainTabBar.delegate = self;
[MainTabBar setViewControllers:[NSArray arrayWithObjects:nav_1,nav_2,nav_3,nil]];
MainTabBar.view.frame=self.view.frame;

[self.view addSubview:MainTabBar.view];

答案 1 :(得分:0)

在viewWillAppear中写一下,我希望它会对你有所帮助

       [self.navigationController setNavigationBarHidden:YES animated:YES];

答案 2 :(得分:0)

您可以检查.Xib,在身份检查器中选中Top Bar,这应该是'None'。