0

I create a NSPopover programmatically like this:

    popViewController *controller = [[popViewController alloc] initWithNibName:@"popViewController" bundle:nil];

    NSPopover *thePopover = [[NSPopover alloc] init];

    [thePopover setBehavior:NSPopoverBehaviorTransient];
    [thePopover setAnimates:YES];
    [thePopover setContentViewController:controller];

    [thePopover showRelativeToRect: [[sender superview] bounds] ofView:[sender superview] preferredEdge:NSMaxXEdge];  

When the function that has this code, is called, the NSPopover appears, but when i click somewhere on the screen, even inside the NSPopover, it closes and i get this error message in the console:

customMenuItem[8530] <Error>: kCGErrorIllegalArgument: _CGSFindSharedWindow: WID 1998
Jul 23 14:55:46 ThousandSunny.local customMenuItem[8530] <Error>: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.
Jul 23 14:55:46 ThousandSunny.local customMenuItem[8530] <Error>: kCGErrorIllegalArgument: CGSRemoveWindowFromWindowMovementGroup: Invalid window  

What is going wrong?

ozmax
  • 470
  • 6
  • 17
  • Do you actually have a xib file named popViewController.xib in your project? I have a vague recollection that `initWithNibName:` will fail silently if it doesn't find the xib file, leaving you with a nil view in the controller. After you init the controller, see if its view is nil or not. – ipmcc Jul 23 '13 at 13:11
  • Yes i do. The view that I have in the nib appears normally, but it closes when I click into it with the error in the console written above. – ozmax Jul 23 '13 at 13:39
  • Also I nslog the nspopover and it is not nil – ozmax Jul 23 '13 at 13:48

0 Answers0