我像这样以编程方式创建一个 NSPopover:
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];
当调用具有此代码的函数时,会出现 NSPopover,但是当我单击屏幕上的某个位置时,即使在 NSPopover 内部,它也会关闭,并且我在控制台中收到以下错误消息:
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
出了什么问题?