[英]How to switch between different ViewControllers or NavigationController in Swift?
I just got into Swift programming lately and I have an easy question I can't answer.我最近刚接触 Swift 编程,我有一个简单的问题我无法回答。
I understood that we start putting a ViewController to show something, then if I want to display another view I can use a segue linked to another view.我知道我们开始放置一个 ViewController 来显示一些东西,然后如果我想显示另一个视图,我可以使用链接到另一个视图的 segue。 But I don't like the fact that the view called by the segue doesn't take the full screen.
但我不喜欢 segue 调用的视图没有全屏显示这一事实。 It just looks like a pop-up screen.
它看起来就像一个弹出屏幕。
So, how could I switch from a ViewController to another ViewController or NavigationController or whatever that keep the fullscreen view.那么,我怎么能从一个 ViewController 切换到另一个 ViewController 或 NavigationController 或任何保持全屏视图的东西。 How could I change my view without passing through a segue and get the following view like a pop-up?
我怎样才能在不通过 segue 的情况下更改我的视图并像弹出窗口一样获得以下视图?
Hope my wonder is clear enough to be answered:D希望我的疑问足够清楚,可以得到解答:D
Thanks a lot to the community !!!非常感谢社区!!!
You can make your segue's presentation style as fullscreen.您可以将您的 segue 的演示风格设为全屏。 But if you want to use UINavigationController, first you need to embed your ViewController in UINavigationController(rootViewController: ViewController()).
但是如果你想使用UINavigationController,首先你需要在UINavigationController(rootViewController: ViewController())中嵌入你的ViewController。 After that you can navigate to another ViewController using pushViewController method.
之后,您可以使用 pushViewController 方法导航到另一个 ViewController。
When you use UINavigationController, it will stack on top of each other.当你使用 UINavigationController 时,它会堆叠在一起。 When you use popViewController, the current ViewController will be popped off from the stack.
当你使用 popViewController 时,当前的 ViewController 将从堆栈中弹出。 That's how works in general.
这就是一般的工作方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.