我有一个 NSButton,单击它时会打开一个 NSPopover,我唯一的问题是,当再次单击该按钮时,NSPopover 会在另一个按钮之上再次打开,弹出窗口使用以下命令打开:
- (IBAction)openSettingsPopover:(id)sender {
NSViewController *controller = [[NSViewController alloc] initWithNibName:@"Settings" bundle:nil];
NSPopover *popover = [[NSPopover alloc] init];
[popover setContentSize:NSMakeSize(288.0f, 170.0f)];
[popover setContentViewController:controller];
[popover setAnimates:YES];
[popover showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMaxXEdge];
}
如果用户在视图之外单击,我将如何关闭弹出窗口而不是打开另一个弹出窗口?提前致谢。