【问题标题】:Show NSWindow as a toolbar sheet将 NSWindow 显示为工具栏工作表
【发布时间】:2012-08-22 14:15:57
【问题描述】:

如何在工具栏中显示NSWindow,如下图中的NSOpenPanel

【问题讨论】:

    标签: macos cocoa nswindow nsopenpanel cocoa-sheet


    【解决方案1】:

    从NIB文件的窗口属性中取消选中Visible At Launch,然后使用beginSheet

    [NSApp beginSheet:sheetWindow
               modalForWindow:mainWindow
               modalDelegate:self
               didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
               contextInfo:NULL];
    

    另外,NSSavePanel 提供了beginSheetModalForWindow 作为一种方便的方法:

    [savePanel beginSheetModalForWindow:mainWindow completionHandler:^(NSInteger result) {
        if (result != NSFileHandlingPanelOKButton) return;
        // Do something
    }];
    

    【讨论】:

      猜你喜欢
      • 2015-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多