[英]Xcode Swift MacOs - Hide/Show windows without a StoryBoard and without ViewController
I'm making an App on my Apple macOS computer by using Swift 3我正在使用 Swift 3 在我的 Apple macOS 计算机上制作应用程序
Close a window is eazy [in this way] from my main window called w
by clicking button and calling the function closeotherw()
通过单击按钮并调用
w
closeotherw()
从我的主要 window 关闭 window 很容易 [以这种方式]
@IBOutlet var w: NSWindow!
@IBOutlet var otherw: NSWindow!
@IBOutlet var otherw: NSPanel!
@IBAction func closeotherw(_ sender: AnyObject) {
otherw.close()
}
But how to reopen-it [otherwin]?但是如何重新打开它[otherwin]?
I also tried it in all ways, also like w.isHidden = true
but with no results.我也以各种方式尝试过,也像
w.isHidden = true
但没有结果。
I don't have a StoryBoard
and I also don't have a ViewController
.我没有
StoryBoard
也没有ViewController
。
I'm doing all from AppDelegate
.我正在从
AppDelegate
做所有事情。
Method is: otherw.orderFront(self)
方法是:
otherw.orderFront(self)
Also there is:还有:
makeKeyAndOrderFront to show it again.
makeKeyAndOrderFront 再次显示它。
You can use otherw.orderOut(self)
instead otherw.close()
您可以使用
otherw.orderOut(self)
代替otherw.close()
tnks to @Willeke tnks 到@Willeke
reference: How to hide the window参考: 如何隐藏 window
Good learning!好好学习!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.