如何在Cocoa Mac应用程序中按钮单击打开一个新窗口? [英] How to open a new window on button click in Cocoa Mac Application?
本文介绍了如何在Cocoa Mac应用程序中按钮单击打开一个新窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何在按钮点击Cocoa Mac编程打开一个新窗口。帮我。我在做一个mac应用程序,需要在特定的按钮点击打开一个新的mac窗口。
I want to know how to open a new window on button click in Cocoa Mac Programming. Help me. I am doing a mac application which needs to open a new mac window on particular button click.
推荐答案
如果你想创建一个新窗口的单独类,这些是步骤:
If you want to create a separate class for New Window, these are the steps:
- 创建一个类,它是NSWindowController的子类NewWindowController
- 为NewWindowController类创建窗口xib。
-
按钮上的代码为:
- Create a class which is a sub class of NSWindowController e.g. NewWindowController
- Create a window xib for NewWindowController class.
On button click code as:
NewWindowController *controllerWindow = [[NewWindowController alloc] initWithWindowNibName:@"You Window XIB Name"];
[controllerWindow showWindow:self];
这篇关于如何在Cocoa Mac应用程序中按钮单击打开一个新窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文