I've created an OS X Cocoa Application using the Swift language in Xcode. I have setup my main storyboard like this:
And when I run the application and hit the button, it opens a new window for the other View Controller like this which is not what I want. This is what I get:
What I want exactly is that the ViewControllers to switch but in the same window, and not in a new window. How do I stop the new window behaviour and make this work in the same window?
1. Create storyboards by File -> New -> File -> Select Storyboard -> Next -> Give it a name -> Create.
In your ViewController where your button action is:
@IBAction func changeView(sender: AnyObject) {
let secondVC = storyboard?.instantiateControllerWithIdentifier("SecondVC") as? SecondViewController
view.window?.contentViewController = secondVC
}
And remember to identify your second viewcontroller like this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With