如何显示从 xib 加载的工作表? (MacOSx)
我有一个 xib 文件,其中只有一个 NSPanel,我试图将此面板显示为模式表(使用 beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:
)。该 xib 文件的所有者是一个控制器类“MyController”,它具有 NSPanel 的 IBOutlet。
我正在寻找的是这样的:
...
MyController *controller = [[MyController alloc] init];
[NSApp beginSheet:controller.panel modalForWindow:[NSApp mainWindow] modalDelegate:controller didEndSelector:nil contextInfo:nil];
...
问题: MyController 必须继承自 NSWindowController
或 NSObject
吗?我尝试了 NSWindowController
和 initWithWindowNibName:
但 NSPanel
的出口始终为零。
谢谢
I have a xib file with only an NSPanel in it, I'm trying to show this panel as modal sheet (with beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:
). The file's owner for this xib is a controller class "MyController" which has the IBOutlet to the NSPanel.
What I am looking for is something like:
...
MyController *controller = [[MyController alloc] init];
[NSApp beginSheet:controller.panel modalForWindow:[NSApp mainWindow] modalDelegate:controller didEndSelector:nil contextInfo:nil];
...
Question:
Must MyController inherit from NSWindowController
or NSObject
?. I tried NSWindowController
and initWithWindowNibName:
but the outlet to NSPanel
always is nil.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我解决了。您必须停用用于工作表的窗口对象(在 IB 中)的几乎所有属性。我将以下方法添加到控制器中以显示工作表:
panelSheet
是工作表窗口的 IBOutlet。感谢 Jon Hess 和 JWWalker 的帮助
I resolve it. You must deactivate almost all the properties of the window object (in the IB) that you are using for the sheet. I add the following method to my controller to show the sheet:
panelSheet
is an IBOutlet to the sheet window.Thanks Jon Hess and JWWalker for your help