How to create a NSPanel modally popuped from NSWindow (Cocoa programming)

一笑奈何 提交于 2019-12-06 07:08:45

问题


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.


回答1:


It can be done like this:

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

Attention:

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.

Result:



来源:https://stackoverflow.com/questions/13881164/how-to-create-a-nspanel-modally-popuped-from-nswindow-cocoa-programming

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!