简体   繁体   English

Swift-TabBarController-> ViewController-> NavigationController

[英]Swift - TabBarController -> ViewController -> NavigationController

i have the following situation: 我有以下情况:

I got a TabBarController with some tabs(ViewControllers). 我有一个带有某些选项卡的TabBarController(ViewControllers)。

When i am in one of these ViewControllers, i tap a button and i want to segue to a NavigationController AND still see the tabbar... 当我在其中一个ViewController中时,我点击一个按钮,然后想选择一个NavigationController并仍然看到选项卡...

Here is what i did: 这是我所做的:

  1. I created a new ViewController(DetailViewController) 我创建了一个新的ViewController(DetailViewController)
  2. I embedded this new ViewController(DetailViewController) in a NavigationController 我将这个新的ViewController(DetailViewController)嵌入了NavigationController中
  3. I created a segue(Show) from the "viewcontroller which is embedded in the tabbarcontroller" to the "new navigationcontroller" 我从“嵌入在tabbarcontroller中的viewcontroller”到“ new navigationcontroller”创建了segue(Show)
  4. I coded: 我编码:

     func buttonTapped { performSegue(withIdentifier: "shownavicontroller", sender: nil } override func prepare(for segue: UIStoryboardSegue, sender: Any?) { let destinationNavigationController = segue.destination as! UINavigationController let targetController = destinationNavigationController.topViewController as! DetailViewController } 

What goes wrong: 出了什么问题:

  1. NavigationController is sliding from bottom to top... it should slide from left to right NavigationController从底部滑到顶部...应该从左滑到右
  2. BackButton in NavigationController is missing NavigationController中的BackButton丢失
  3. TabBar in NavigationController is missing... NavigationController中的TabBar丢失...

Anybody could help me with this issue? 有人可以帮助我解决这个问题吗?

Thanks and Greetings!! 谢谢和问候!

You have done wrong. 你做错了。 You should not embed UIViewController directly to tabBarController to get the desired result you want. 您不应将UIViewController直接嵌入到tabBarController中以获得所需的所需结果。

From Storybaord, 从Storybaord,

If you are designing your application from storyboard then you should add a UIViewController and embed this UIViewController object into UINavigationController and then embed this NavigationController in a UITabBarController . 如果要从情节提要中设计应用程序,则应添加UIViewController并将此UIViewController对象嵌入UINavigationController ,然后将此NavigationController嵌入UITabBarController So that if a button in above UIViewController is pressed and you need to open an other UIViewController not form Bottom to Top but from Left to Right and expecting a Automatic back button at top bar and hide bottom bar. 因此,如果按下了UIViewController上方的按钮,则需要打开另一个UIViewController而不是从下到上,而是从左到右,并希望在顶部栏自动隐藏按钮,并隐藏底部栏。 Then you need to create a Push/Show Segue form Above ViewController (Embed in NavigationController -> Embed in TabBarController ) to you new UIViewController that will open. 然后,您需要在ViewController上方创建一个Push / Show Segue表单(嵌入到NavigationController ->嵌入到TabBarController )到要打开的新UIViewController。 And before calling the push/show segue you need to write bellow lines. 在调用“推送/显示”序列之前,您需要编写波纹管。

self.tabBarController?.hidesBottomBarWhenPushed = true

According to your question i believe this is what you need: 根据您的问题,我相信这是您需要的:

在此处输入图片说明

在此处输入图片说明

暂无
暂无

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

相关问题 在TabBarController内部的NavigationController中从(Table)ViewController呈现模态ViewController - Presenting Modal ViewController from (Table)ViewController inside a NavigationController inside a TabBarController 从嵌入在TabBarController和NavigationController中的ViewController推送新的ViewController - Pushing a new ViewController from a ViewController that is embedded in a TabBarController and NavigationController 快速更新嵌入在navigationController中的tabBarController中的视图的barButtonItems - Swift updating barButtonItems for a view embedded in a tabBarController in a navigationController 具有NavigationController的TabBarController - TabBarController with NavigationController TabBarController和NavigationController - TabBarController and NavigationController 打开ViewController(它是tabBarController中的navigationController)并运行功能 - Open ViewController (which is a navigationController within a tabBarController) and run function iOS从tabbarcontroller中的navigationcontroller推送viewcontroller但未显示 - IOS pushing viewcontroller from navigationcontroller in a tabbarcontroller but does not show 以编程方式导航到另一个故事板上的navigationcontroller和tabbarcontroller内的viewcontroller - Navigate programmatically to viewcontroller inside navigationcontroller & tabbarcontroller on another storyboard Swift如何检查TabBarController中的ViewController是否为特定类 - Swift How to check if ViewController in TabBarController is a particular class Swift-从NavigationController中的UIViewController到TabBarController中的UIViewController的筛选 - Swift - Segue from UIViewController within NavigationController to UIViewController within TabBarController
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM