我试图在窗口打开时给mac用户显示一个NSPopover,以便给用户一条指令,但popover不会显示。在窗口中打开NSPopoverDidLoad
如果我从一个按钮调用完全相同的功能,然后popover成功显示,但是当我在windowDidLoad中调用它时,它不会。
我可以看到,我介绍它的控件有一个界限,所以我不认为这是问题。我也检查过popover的行为不是短暂的,所以不应该在没有干预的情况下关闭。
在我的功能我传递一些变量到自定义初始化器,但它基本上是这样的:
CustomViewController *instruction = [[CustomViewController alloc] init];
[instruction.popover showRelativeToRect:[aField bounds] ofView:aField preferredEdge:NSMaxXEdge];
init方法简单地调用下面,和自定义视图和控制器中挂接NIB。
[super initWithNibName:@"InstructionalView" bundle:nil]
有没有人来过这个?
你能显示实际设置“'.popover'”属性的代码吗? –
它是CustomViewController上的一个属性,关系在NIB中设置。 '@property(assign)IBOutlet NSPopover * popover;'。 我的CustomViewController是NIB的文件所有者类,并且是popover的contentViewController。 – DownUnder