0

The main window in my OS X app is based on a NSWindow. How do I show a popup view/window from a NSWindow?

I tried the following:

NSViewController* vc = [[NSViewController alloc] initWithNibName:@"DialogConfirm" bundle:nil];
[self beginSheet:vc.view.window completionHandler: nil];

but vc.view.window is nil.

  • view.window is nil because it doesn't have one. So create an NSWindow, setup your view in the window, and then show that window. – rocky May 24 '16 at 22:16
  • So you suggest to create a new NSWindow and assign it to vc.view.window? – Ole Bjørn Setnes May 25 '16 at 09:56
  • 1
    I'm suggesting that you create a new NSWindow, then add your NSView as a subview to window.contentView and then call [self beginSheet:window ...] – rocky May 25 '16 at 19:22
  • Thanks, it works. I found out that for my purpose it was better to use NSWindowControl with the method showWindow. – Ole Bjørn Setnes May 31 '16 at 14:33

0 Answers0