How to create a multi-page application using Swift for OS X?

I created an OS X Cocoa application using the Swift language in Xcode. I set my main storyboard as follows:

Main storyboard

And when I launch the application and press the button, it opens a new window for another View Controller, like this, which I donโ€™t want. This is what I get:

Show

What I want is exactly what ViewControllers need to switch, but in the same window, not in a new window. How to stop the behavior of a new window and make this work in the same window?

+6
source share
1 answer

In your ViewController where the button action is acting:

@IBAction func changeView(sender: AnyObject) { let secondVC = storyboard?.instantiateControllerWithIdentifier("SecondVC") as? SecondViewController view.window?.contentViewController = secondVC } 

And don't forget to identify your second view manager like this enter image description here

+5
source

All Articles