我正在编写一个加载到状态栏中的简单应用程序,单击该应用程序会在状态栏图标下打开一个弹出框。我正在使用情节提要板定义要在弹出窗口中显示的UI。事情是,一旦我实例化情节提要,就会打开一个窗口。我该如何预防?这是我的应用程序委托中的代码:
func applicationDidFinishLaunching(aNotification: NSNotification) {
let mainBoard = NSStoryboard(name: "MainBoard", bundle: nil)
}
import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
var defaultWindow:NSWindow!
func applicationDidFinishLaunching(aNotification: NSNotification) {
defaultWindow = NSApplication.sharedApplication().windows.first as? NSWindow
defaultWindow.close()
}
func applicationWillTerminate(aNotification: NSNotification) {
// Insert code here to tear down your application
}
@IBAction func menuClick(sender: AnyObject) {
defaultWindow.makeKeyAndOrderFront(nil)
}
}
更新:Xcode 7.1.1•Swift 2.1
NSApplication.sharedApplication().windows.first?.close()
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句