【发布时间】:2016-08-15 15:48:48
【问题描述】:
我已经制作了一个窗口 xib 和 cocoa 类文件 (nswindowcontroller),需要通过主窗口的按钮操作从 xib 显示窗口。
【问题讨论】:
-
欢迎来到 StackOverflow。请发布您目前拥有的代码,以更好地帮助其他用户了解您的确切问题。
标签: cocoa xib swift3 nswindowcontroller xcode8
我已经制作了一个窗口 xib 和 cocoa 类文件 (nswindowcontroller),需要通过主窗口的按钮操作从 xib 显示窗口。
【问题讨论】:
标签: cocoa xib swift3 nswindowcontroller xcode8
在你的主 NSWindowController 中:
在界面中:
@property (nonatomic, strong) CustomWindowController *windowController;
在实现中:
- (IBAction)didPressOpenWindowButton:(id)sender {
CustomWindowController *wc = [[CustomWindowController alloc] init];
[wc showWindow:nil];
[wc.window makeKeyAndOrderFront:nil];
_windowController = wc;
}
将您的 IBAction 连接到主窗口中的 NSButton。
【讨论】: