【问题标题】:Navigation Controller not pushing new window导航控制器不推送新窗口
【发布时间】:2014-12-17 14:28:23
【问题描述】:

我需要在我的视图控制器上将标签栏位置更改为顶部,我发现了如何做到这一点。问题是现在在其中一个选项卡中我需要推送一个新的视图控制器,但是当我这样做时,导航栏不会出现。我尝试将新的视图控制器嵌入到另一个导航控制器中并且它可以工作(显示导航栏)但它没有显示后退按钮项。有没有办法做到这一点?

这里有一些屏幕截图:

这就是我在标签之间导航的方式

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
switch (item.tag) {
    case 1:
        if (Home == nil) {
            UIStoryboard*  sb = [UIStoryboard storyboardWithName:@"Main"
                                                          bundle:nil];
            Home = [sb instantiateViewControllerWithIdentifier:@"Home"];
        }
        [self.view insertSubview:Home.view belowSubview:mainTabBar];
        break;
    case 2:
        if (Activity == nil) {
            UIStoryboard*  sb = [UIStoryboard storyboardWithName:@"Main"
                                                          bundle:nil];
            Activity = [sb instantiateViewControllerWithIdentifier:@"Activity"];
        }
        [self.view insertSubview:Activity.view belowSubview:mainTabBar];
        break;

    case 3:
        if (Discover == nil) {
            UIStoryboard*  sb = [UIStoryboard storyboardWithName:@"Main"
                                                          bundle:nil];
            Discover = [sb instantiateViewControllerWithIdentifier:@"Discover"];
        }
        [self.view insertSubview:Discover.view belowSubview:mainTabBar];
        break;
    case 4:
        if (Profile == nil) {
            UIStoryboard*  sb = [UIStoryboard storyboardWithName:@"Main"
                                                          bundle:nil];
            Profile = [sb instantiateViewControllerWithIdentifier:@"Profile"];

        }
        [self.view insertSubview:Profile.view belowSubview:mainTabBar];
        break;
    default:
        break;
}

这是我需要推送的视图控制器。

【问题讨论】:

    标签: ios objective-c iphone uinavigationcontroller uitabbarcontroller


    【解决方案1】:

    而不是在选择控制器时实例化它们,您应该实例化它们并将它们添加到数组中,然后在设置窗口时在 AppDelegate 中执行此操作: self.tabBarController.viewControllers = localViewControllersArray;

    【讨论】:

      【解决方案2】:

      以防万一有人需要这个,我解决它的方法是使所有选项卡视图控制器成为主视图控制器的子视图,以便它自己管理导航。

      [self addChildViewController:self.Home];
      

      【讨论】:

        猜你喜欢
        • 2013-07-19
        • 2014-01-11
        • 1970-01-01
        • 1970-01-01
        • 2016-08-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-07-14
        相关资源
        最近更新 更多