Reputation: 1532
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?
Upvotes: 6
Views: 4352
Reputation: 1681
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
Upvotes: 6