移动到另一个视图控制器时保持TabBar [英] Keep TabBar when moving to another view controller

查看:102
本文介绍了移动到另一个视图控制器时保持TabBar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的故事板

- > NavigationController - > LoginView - > TabBarController - > VC1 - > VC2

-> NavigationController -> LoginView -> TabBarController -> VC1 -> VC2

我没有设法从VC1移动到VC2保持标签栏。

I didn't manage to make a "move" from VC1 to VC2 keeping the tab bar.

我尝试了以下内容:


  • Segue(显示类型)

  • Segue (Show type)

self.performSegueWithIdentifier("toVC2segue", sender: self)


  • 实例化programmaticaly:

  • instantiate programmaticaly :

    // prepare for future display
    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let navigationVC = UIApplication.sharedApplication().keyWindow?.rootViewController as! UINavigationController
    
    // prepare next view
    let vc = storyboard.instantiateViewControllerWithIdentifier("VC2id")
    
    self.tabBarController?.navigationController?.pushViewController(vc, animated: true)
    


  • 但两者都成为标签栏消失了。

    but both make the tab bar disappearing.

    我也试过了

    self.hidesBottomBarWhenPushed = false
    

    但这并未改变任何内容。

    but this didn't change anything.

    你有另外一个想法吗?

    PS:我在上面更新了我的方案......

    PS : I updated my scheme above...

    编辑:之后阅读下面的答案,我试图添加另一个导航控制器:

    Edit : After reading the answers below, I tried to add another navigation controller :

    - > NavigationController - > LoginView - > TabBarController - > NavigationController - > VC1 - > VC2

    -> NavigationController -> LoginView -> TabBarController -> NavigationController -> VC1 -> VC2

    但我现在有2个导航条叠加在VC1和VC2中...

    but I have now 2 navigation bars superposed in VC1 and VC2...

    推荐答案

    您需要将TabBarContoller设置为应用程序的rootViewController。所以方案应该如下:

    You need to set TabBarContoller as rootViewController of the app. So scheme should be as follow:


    TabBarContoller - > Tab1 - > UINavigationController - > ViewContoller1 - >
    ViewContoller2。

    TabBarContoller -> Tab1 -> UINavigationController -> ViewContoller1 -> ViewContoller2.

    在这种情况下,您可以在ViewContoller1和ViewContoller2之间导航,TabBarContoller将保持可见。

    In such case you can navigate between ViewContoller1 and ViewContoller2 and TabBarContoller will remain visible.

    这篇关于移动到另一个视图控制器时保持TabBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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