[英]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: 这是我所做的:
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: 出了什么问题:
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.