使用窗口关闭按钮完全关闭OS X应用程序 [英] Completely close an OS X application with window close button
问题描述
当用户在运行时使用应用程序关闭文档窗口时,我需要完全关闭我的应用程序.
I need completely close my application when a user closes the document window using the applications at runtime.
当前,当他们单击窗口时,该应用程序保持打开状态并显示其菜单栏.我为iOS阅读了这篇文章,并在plist文件中添加了一个条目: http://developer.appcelerator.com/question/40081/ios4 --- make-app-not-run-in-background
Currently when they click the window, the application stays open and is displaying its menu bar. I read this article for iOS and to add an entry into the plist file: http://developer.appcelerator.com/question/40081/ios4---make-app-not-run-in-background
当用户关闭文档窗口时,关闭整个应用程序最简单的方法是什么?
What is the easiest way for me to close the entire app when a user closes the document window?
推荐答案
这是Mac应用程序吗?如果是这样,请让您的NSApp
委托实现 applicationShouldTerminateAfterLastWindowClosed:
:
Is this a Mac app? If so, have your NSApp
delegate implement applicationShouldTerminateAfterLastWindowClosed:
:
- (BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)application
{
return YES;
}
使用Swift,它将是:
Using Swift, it would be:
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true
}
这篇关于使用窗口关闭按钮完全关闭OS X应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!