当主窗口关闭时,使Cocoa应用程序退出? [英] Make a Cocoa application quit when the main window is closed?

查看:105
本文介绍了当主窗口关闭时,使Cocoa应用程序退出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在主窗口关闭时退出Cocoa应用程序?如果没有,您必须点击应用程序图标,然后点击菜单中的退出。


<您可以实现 applicationShouldTerminateAfterLastWindowClosed:在您的应用程序的委托中返回YES。但我会考虑两次,在这之前,因为它是真正不寻常的Mac上小的实用程序应用程序,如计算器和大多数Mac用户不会感谢你的应用程序的行为这么奇怪。


How to make a Cocoa application quit when the main window is closed? Without that you have to click on the app icon and click quit in the menu.

解决方案

You can implement applicationShouldTerminateAfterLastWindowClosed: to return YES in your app's delegate. But I would think twice before doing this, as it's really unusual on the Mac outside of small "utility" applications like Calculator and most Mac users will not appreciate your app behaving so strangely.

这篇关于当主窗口关闭时,使Cocoa应用程序退出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆