【问题标题】:How to create a NSPanel modally popuped from NSWindow (Cocoa programming)如何创建从 NSWindow 模态弹出的 NSPanel(Cocoa 编程)
【发布时间】:2012-12-14 15:03:41
【问题描述】:

就像在 NSWindow 中单击按钮后显示的 NSPanel。

我找了很多,但没有简单的例子。 感谢您的帮助。

【问题讨论】:

    标签: xcode modal-dialog nswindow nspanel


    【解决方案1】:

    可以这样做:

    -(IBAction)showButtonAction:(id)sender {
        [[NSApplication sharedApplication] beginSheet:panelOutlet
                                       modalForWindow:self.window
                                        modalDelegate:self
                                       didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
                                          contextInfo:nil];
    }
    

    注意:

    不要忘记取消选中 NSPanelVisible At Launch 复选框 Attributes InspectorRelease When Closed 如果您不会使用此面板一次。

    结果:

    【讨论】:

    • Swift 等价物? ty
    • 这不是NSSheet而不是NSPanel吗?
    猜你喜欢
    • 1970-01-01
    • 2015-03-17
    • 2020-06-22
    • 2021-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多