如何将其他视图控制器推到NavigationController上但保留TabBar? [英] How to push additional view controllers onto NavigationController but keep the TabBar?

查看:61
本文介绍了如何将其他视图控制器推到NavigationController上但保留TabBar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,该应用程序从导航控制器的根部的基本视图控制器开始

I have an app that starts with a basic view controller at the root of my navigation controller

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.navController.viewControllers = [NSArray arrayWithObject:[self getHomeViewController]];

    [[self getWindow] addSubview:self.navController.view];
    [[self getWindow] makeKeyAndVisible];

    return YES;
}

一旦选择了导航项,我便会按下带有一些按钮的标签栏控制器

Once a navigation item is selected I push a tab bar controller w/ a few view controllers.

-(void)launchOptionWithTabBarController:(NSUInteger)selectedIndex
{
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:
                                             [self getFirstViewController], 
                                             [self getSecondViewController],
                                             nil];

    [self.tabBarController setSelectedIndex:selectedIndex];
    [self.navController pushViewController:self.tabBarController animated:YES];
}

问题是我现在需要在顶部添加另一个视图控制器一个在标签栏控制器中打开...然后当我将一个推入导航控制器时..

The problem is that I now need to add another view controller on top of the one open in the tab bar controller ... and when I push one to the navigation controller like so ..

- (void)launchNewViewControllerWithArray:(NSArray *)stuff
{
    self.newViewController = [self getNewViewController];

    [self.navController pushViewController:self.newViewController animated:YES];
}

我不再看到标签栏导航(我希望看到此导航/带有我推入的每个项目)。

I no longer see the tab bar navigation (and I would prefer to see this nav w/ each item I push).

如何修改控制流,使标签栏导航项目始终位于底部?

How can I modify my control flow so the tab bar nav items stay along the bottom?

推荐答案

您需要在选项卡控制器中将导航控制器作为父级,而不是相反。或在标签栏控制器上引入另一个导航控制器,并将新的viewcontroller推到该控制器上。

You need to parent the navigation controller in the tabbar controller instead of vice versa. Or introduce another navigation controller parented on your tabbar controller, and push the new viewcontroller onto that.

这篇关于如何将其他视图控制器推到NavigationController上但保留TabBar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆