I want the ViewController with the contents of the window to switch to another ViewController at the click of a button. But I can only open a new window.

Can be used:

[self presentViewControllerAsSheet:controllerNew]; 

But then another controller opens on top of the old one without closing. In addition, he has animation, but I do not need animation.

How to open ViewController in an existing ViewController?

In the iOS project, I do this:

 [self.navigationController pushViewController:secondViewController animated:NO]; 

It’s also interesting what the animator in this function:

 [self presentViewController:controllerNew animator: ]; 

Where to get it? And in general, what is it? Googled, googled, did not find examples.

  • No answers? :) - developer
  • I don’t know your goals, but generally in osx everything is built around nswindow windows containing one or more views and their nswindowscontroller controllers, view controllers are rarely used, it makes sense only for complex reusable views -
  • Do you use storyboards or use the classic approach with xib? - Sega-Zero
  • @ Sega-Zero, Storyboards - developer

1 answer 1

To have a behavior similar to iOS, you just need to override the work of the segway in the perform method. There is a turnkey solution in the form of GRPushSegue . I strongly recommend watching the video about OSX storyboards with WWDC so that in the future there will be no misunderstandings about how to work with them correctly. Get rid of iOS approaches :)

  • By the way, one of my main.storyboard doesn’t open in the GRPushSegue project? XCode crashes. - developer
  • Apparently yes. Everything works well for me. - Sega-Zero
  • Do you have OS X? I have 10.10, was not updated on 10.10.3. - developer
  • probably have to upgrade :) - Sega-Zero
  • Updated, now all the buzz :). - developer