简体   繁体   English

当segue到另一个ViewController时,TabBar嵌入式NavigationController栏会消失

[英]TabBar embedded NavigationController bar disappears when segue to another ViewController

I have a UITabBarController which is connected to 3 UINavigationControllers. 我有一个UITabBarController连接到3个UINavigationControllers。 Each of these have a UIViewController as a root view controller. 其中每个都有一个UIViewController作为根视图控制器。 When I click on a button in one of these ViewControllers (VC1), I want it to segue to new ViewController (VC2). 当我单击其中一个ViewControllers(VC1)中的按钮时,我希望它转到新的ViewController(VC2)。 Simple enough. 很简单。

During runtime, when the segue takes place and VC2 appears, the navigation bar disappears. 在运行期间,当segue发生并且VC2出现时,导航栏消失。

The navigation bar is present in the storyBoard / interface builder, and the segue is the type: present (Push). 导航栏出现在storyBoard / interface构建器中,segue是类型:present(Push)。

Code in VC1: VC1中的代码:

@IBAction func create_clicked(_ sender: Any) {
    performSegue(withIdentifier: "segueIdentifier", sender: self)
}

It might help to know how the UITabBarController tabBar is instantiated: 了解如何实例化UITabBarController tabBar可能会有所帮助:

func login() {

    let storyBoard = UIStoryBoard(name: "Main", bundle: nil)
    let tabBar = storyBoard.instantiateViewController(withIdentifier: "tabBar")

    window?.rootViewController = tabBar
}

Please help. 请帮忙。

After a great deal of experimentation, we determined that even though Interface Builder said this was a Show (Push) segue, and even though we were in a Navigation Controller to start with, it was behaving as a Present Modally segue. 经过大量的实验,我们确定即使Interface Builder 这是一个Show(Push)segue,即使我们在一个导航控制器中开始,它也表现为一个现在的模态segue。

So we changed the segue type, using the pop-up menu in Interface Builder, from Show (Push) to plain Push, even though that's deprecated — and the interface worked correctly. 所以我们使用Interface Builder中的弹出菜单,从Show(Push)到普通Push,改变了segue类型,即使这已被弃用 - 并且界面正常工作。

And then we changed it back to Show (Push) and the interface continued to work correctly. 然后我们将其更改回Show(推送),界面继续正常工作。 Problem solved! 问题解决了!

I suspect the storyboard was corrupted in some way. 我怀疑故事板在某种程度上被破坏了。 Obviously Interface Builder should not lie to you about what kind of segue this is, but basically, that is what it seems to have been doing. 显然,Interface Builder不应该对你说这是什么样的segue,但基本上,这就是它似乎一直在做的事情。

EDIT The problem was caused, apparently, by making a Show Detail segue and changing it to Show. 编辑问题是由于显示详细信息并将其更改为显示而引起的。 When you do that, it's still a Show Detail segue, which in this context behaves as a modal presentation. 当你这样做时,它仍然是一个Show Detail segue,在这个上下文中表现为一个模态表示。 That's an Xcode bug! 这是一个Xcode错误! I reported it, and Apple now says this will be fixed in Xcode 9.3. 我报告了它,Apple现在说这将在Xcode 9.3中修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从ViewController选择(推送)到NavigationController中嵌入的另一个ViewController? - How to segue (push) from ViewController to another ViewController embedded in NavigationController? 当从一个ViewController到另一个ViewController执行show segue时,导航栏消失了? - Navigation bar disappears when show segue is executed from one ViewController to another? 当程序化搜索时,TabBar消失 - TabBar disappears when programatic segue 甚至在NavigationController Swift中搜索时,TabBar也会消失 - TabBar disappear when segue even NavigationController Swift 搜索后标签栏消失 - Tabbar disappears after segue 为什么在推送序列时ViewController包含NavigationController时未声明? - Why does a ViewController not declare when it contains a NavigationController when pushing a segue? 当NavigationController将视图弹出回到上述ViewController时,UITabBar消失 - UITabBar disappears when NavigationController pop the view back to the said ViewController 在一个标签栏控制器中从一个ViewController切换到另一个ViewController? - Segue from one ViewController to another ViewController inside a Tab Bar Controller? 推送到下一个viewController时导航栏消失 - Navigation bar disappears when pushing to the next viewController 如何与NavigationController共享TabBar中的ViewController类? - How to share the ViewController class in TabBar with NavigationController?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM