在NSMenuItemtitle Hide action #selectorNSApplicationhideOtherApplications_ keyEquivalent H如何在action里打开某个Window
可以使用以下代码在action中打开窗口:
let windowController = NSStoryboard(name: "Main", bundle: nil).instantiateController(withIdentifier: "windowController") as! NSWindowController
windowController.showWindow(nil)
这里使用了NSStoryboard来获取窗口控制器对象,并调用showWindow方法来显示窗口。需要注意的是,需要在Main.storyboard中给窗口控制器设置一个唯一的标识符,这里使用了字符串"windowController"作为标识符。
原文地址: https://www.cveoy.top/t/topic/f8Pr 著作权归作者所有。请勿转载和采集!