【发布时间】:2011-08-03 16:29:14
【问题描述】:
我正在做一个应用程序,我想知道如何显示这样的视图:
【问题讨论】:
标签: macos cocoa nsview cocoa-sheet
我正在做一个应用程序,我想知道如何显示这样的视图:
【问题讨论】:
标签: macos cocoa nsview cocoa-sheet
那将被称为一张纸。 This 指南将指导您完成操作。
你基本上制作了一个NSWindow,你想将它用作工作表,然后,当你想显示它时,调用:
[NSApp beginSheet: myCustomSheet modalForWindow: window modalDelegate: self didEndSelector: @selector(didEndSheet:returnCode:contextInfo:) contextInfo: nil];`
myCustomSheet 显然是您的工作表,window 是您希望它出现的窗口。将self 设置为委托并实现didEndSheet:returnCode:contextInfo::
- (void)didEndSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
{
[sheet orderOut:self];
}
将工作表上的“关闭”按钮连接到关闭工作表的 IBAction。
- (IBAction)closeMyCustomSheet: (id)sender
{
[NSApp endSheet:myCustomSheet];
}
这些床单甚至不需要折叠!呵呵
【讨论】:
这就是所谓的模态对话框。您可以通过拖入(或从代码中加载)单独的 NSPanel 或 NSWindow 来创建一个,并使用runModal... 方法之一显示它。
【讨论】: