如何创建从NSWindow模态弹出的NSPanel(可可编程) [英] How to create a NSPanel modally popuped from NSWindow (Cocoa programming)

查看:850
本文介绍了如何创建从NSWindow模态弹出的NSPanel(可可编程)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

类似于在NSWindow中单击按钮后显示的NSPanel.

like NSPanel displayed after a button clicked in the NSWindow.

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

I looked for a lot but there is no simple example. Thanks for any help.

推荐答案

可以这样做:

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

注意:

不要忘记取消选中NSPanel启动时可见复选框 属性检查器关闭时发布,如果您不会一次使用此面板.

Don't forget to uncheck NSPanel's Visible At Launch checkbox in Attributes Inspector and Release When Closed if you will use this panel not once.

结果:

这篇关于如何创建从NSWindow模态弹出的NSPanel(可可编程)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆