【问题标题】:Xcode Swift MacOs - Hide/Show windows without a StoryBoard and without ViewControllerXcode Swift MacOs - 隐藏/显示没有 StoryBoard 和 ViewController 的窗口
【发布时间】:2021-06-03 18:08:47
【问题描述】:

我正在使用 Swift 3 在我的 Apple macOS 计算机上制作应用程序

通过单击按钮并调用函数closeotherw(),从我称为w 的主窗口中[以这种方式] 关闭一个窗口很容易

@IBOutlet var w: NSWindow!
@IBOutlet var otherw: NSWindow!
    @IBOutlet var otherw: NSPanel!
    @IBAction func closeotherw(_ sender: AnyObject) {
        otherw.close()
    }

但是如何重新打开它[otherwin]?

我也尝试了各种方式,也喜欢w.isHidden = true,但没有结果。

我没有StoryBoard,也没有ViewController

我在AppDelegate做所有事情。

【问题讨论】:

  • 这能回答你的问题吗? How to hide the window
  • @Willeke 不。如果我让otherw.orderOut() 错误是Missing argument for parameter #1 in call
  • @Willeke tnks 它工作otherw.orderOut(self)it 方式

标签: swift xcode macos cocoa appdelegate


【解决方案1】:

方法是: otherw.orderFront(self)

还有:

makeKeyAndOrderFront 再次显示它。

您可以使用otherw.orderOut(self) 代替otherw.close()

发送给@Willeke

参考: How to hide the window

好好学习!

【讨论】:

    猜你喜欢
    • 2010-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多