【问题标题】:How to load and show window from xib file如何从 xib 文件加载和显示窗口
【发布时间】:2016-08-15 15:48:48
【问题描述】:

我已经制作了一个窗口 xib 和 cocoa 类文件 (nswindowcontroller),需要通过主窗口的按钮操作从 xib 显示窗口。

【问题讨论】:

  • 欢迎来到 StackOverflow。请发布您目前拥有的代码,以更好地帮助其他用户了解您的确切问题。

标签: cocoa xib swift3 nswindowcontroller xcode8


【解决方案1】:

在你的主 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。

【讨论】:

  • @property (nonatomic, strong) CustomWindowController *windowController;
  • @property (nonatomic, strong) CustomWindowController *windowController;不工作我正在使用 xcode 8,swift 3
猜你喜欢
  • 1970-01-01
  • 2012-07-31
  • 1970-01-01
  • 2012-11-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-29
  • 1970-01-01
相关资源
最近更新 更多