【发布时间】:2013-08-04 05:12:35
【问题描述】:
当窗口打开时,我试图在 mac 应用程序中显示 NSPopover 以向用户提供指令,但弹出窗口不会显示。
如果我通过按下按钮调用完全相同的函数,则弹出框会成功显示,但是当我在 windowDidLoad 中调用它时却没有。
我可以看到我展示它的控件有一个界限,所以我认为这不是问题。我还检查了弹出框的行为不是暂时的,所以它不应该在没有干预的情况下关闭。
在我的函数中,我将一些变量传递给自定义初始化程序,但基本上就是这样:
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 的 File 的 Owner 类,是 popover 的 contentViewController。