1 新建一个NSWindowController的子类FileSaveWindowController
2 新建的xib文件,fileOwner设置为FileSaveWindowController类型,关联window
3 调用窗口,如下:
FileSaveWindowController *_savePathWindow;
_savePathWindow = [[FileSaveWindowController alloc] initWintWindowNibName:@"FileSaveWindowController"];
[_savePathWindow loadWindow];
Mac中对话框显示方法有两种,一种跟windows的对话框一样,另一种为Sheet(卷帘式)对话框。
windows风格的对话框,分模态和非模态
非模态:[[dialogCtl window] makeKeyAndOrderFront:nil];
模态:[NSApp runModalForWindow:[dialogCtl window]];
sheet对话框都是模态对话框,显示方式:
NSApp beginSheet:[dialogCtl window]
modalForWindow:[NSApp mainWindow]
modalDelegate:nil
didEndSelector:nil
contextInfo:nil];
[NSApp runModalForWindow:[dialogCtl window]];
如果使用sheet方式的对话框,在对话框退出时,需要在DialogController中调用如下代码:
[NSApp stopModal];
[NSApp endSheet:[self window]];
[[self window] orderOut:nil];