Home > Net >  How to switch between different ViewControllers or NavigationController in Swift?
How to switch between different ViewControllers or NavigationController in Swift?

Time:02-11

I just got into Swift programming lately and I have an easy question I can't answer.

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. But I don't like the fact that the view called by the segue doesn't take the full screen. 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. How could I change my view without passing through a segue and get the following view like a pop-up ?

Hope my wonder is clear enough to be answered :D

Thanks a lot to the community !!!

CodePudding user response:

You can make your segue's presentation style as fullscreen. But if you want to use UINavigationController, first you need to embed your ViewController in UINavigationController(rootViewController: ViewController()). After that you can navigate to another ViewController using pushViewController method.

When you use UINavigationController, it will stack on top of each other. When you use popViewController, the current ViewController will be popped off from the stack. That's how works in general.

  • Related