最近在做一个好玩的OSX上的软件,欢迎关注我微博哦http://weibo.com/u/2009667563/home?wvr=5&lf=reg
本文在简书的地址:http://www.jianshu.com/p/dedb26762055
func applicationShouldHandleReopen(sender: NSApplication, hasVisibleWindows
flag: Bool) -> Bool {
if !flag{
let sb = NSStoryboard(name: "Main", bundle: nil)
let controller = sb?.instantiateInitialController() as
NSWindowController
controller.window?.makeKeyAndOrderFront(self)
self.window = controller.window
}
return true
}
func applicationShouldHandleReopen(sender: NSApplication, hasVisibleWindows
flag: Bool) -> Bool {
if !flag{
for window in sender.windows{
if let w = window as? NSWindow{
w.makeKeyAndOrderFront(self)
}
}
}
return true
}
var mainWindow: NSWindow!
func applicationDidFinishLaunching(aNotification: NSNotification) {
mainWindow = NSApplication.sharedApplication().windows[0] as! NSWindow
}
func applicationShouldHandleReopen(sender: NSApplication, hasVisibleWindows
flag: Bool) -> Bool {
if !flag{
mainWindow.makeKeyAndOrderFront(nil)
}
return true
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
Swift语言 OS X程序点击dock图标重新弹出窗口方法
原文地址:http://blog.csdn.net/li962429707/article/details/46837405