Pregunta

In current NSWindowController, add a child window (mainViewController.window),then close current window,BUT when the method [self.window close] is called, the App terminated(not crash,because I can get the log message form method windowWillClose);

[self.window addChildWindow:mainViewController.window ordered:NSWindowAbove];
[self.window close];

What I want is : close current window when a new window showed.Is my way wrong?

=================================== UPDATE ====================================

Thanks @rdelmar, my mistake ,the App is not terminated,just all windows closed .

[self.window orderFront:mainViewController.window];
[self.window close];
¿Fue útil?

Solución

If you want to close one window when you open another, then you shouldn't make that second window a child of the first. When you close a child window's parent window, the child will close also. You can just create a new window in code and then use orderFront or makeKeyAndOrderFront: to bring it on screen, then close your other window. You could also add another window in IB, and uncheck Visible At Launch so it will only show up when you call one of the methods I mentioned above.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top