我正在做一个应用程序,我想知道如何显示这样的视图:

那将被称为一张纸。本指南应指导您完成这些操作。
您基本上制作了一个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];
}
这些床单甚至不需要折叠!XD
这就是所谓的模态对话框。您可以通过拖入(或从代码加载)单独的 NSPanel 或 NSWindow 来创建一个,并使用其中一种runModal...方法显示它。