0

How can I open the ViewController window through the code? Or do I need to create an NSWindow for this ViewController?

Nikita Goncharuk
  • 795
  • 1
  • 8
  • 23

2 Answers2

0

There is no direct way to push the controller, instead you have to write your own code for view animation and view control addition. In swift we can achieve it as following:

func addSSChildViewController(child:NSViewController){
  let subView = child.view;//Child
  let parent = self.view;//Parent
  self.addChildViewController(child)
  parent.addSubview(subView)

}

Where self is parent NSViewController inherited class.

Satendra dagar
  • 504
  • 4
  • 6
  • That is, if I only have access to the ViewController, I can not open another ViewController? What is the self field, maybe like this? – Nikita Goncharuk Feb 14 '18 at 09:29
  • `var viewController = new SettingsViewController(new IntPtr()); this.AddChildViewController(viewController); this.View.AddSubview(viewController.View);` When i run this code, the application just hangs – Nikita Goncharuk Feb 14 '18 at 09:45
  • I think that I'm not creating ViewController correctly because the program breaks down into this.AddChildViewController(viewController); – Nikita Goncharuk Feb 14 '18 at 09:52
0

Ok, I found a workaround for my problem: method PerformSegue("SignInSegue", this); I set the segue identificator in storyboard(Xcode) and then use it in method.

Nikita Goncharuk
  • 795
  • 1
  • 8
  • 23