关闭Mac应用程序(单击顶部的红色十字),然后通过单击停靠图标重新打开 [英] Closing Mac application (clicking red cross on top) and reopening by clicking dock icon

查看:250
本文介绍了关闭Mac应用程序(单击顶部的红色十字),然后通过单击停靠图标重新打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我关闭我的Mac应用程序(通过点击窗口顶部栏上的红色十字按钮),应用程序图标停留在底部的dock。现在这是正常的行为。当用户再次单击它时,它不会启动应用程序,除非用户完全退出应用程序并重新启动它。

When I close my Mac application (by clicking red cross button on window top bar) the app icon stays in the dock at the bottom. Now this is normal behaviour. When user click on it again it does not fire up the application unless the user quits the application altogether and relaunches it again.

Mac OS X上的类似示例是Activity监控。您可以通过单击顶部的红色十字按钮关闭应用程序,但是停靠图标停留在那里。

A similar example on Mac OS X is "Activity Monitor". You can close the application by clicking the red cross button at the top the but dock icon stays there. User can re-open it by clicking dock icon.

如何在我自己的应用程序中实现?

How can I achieve this in my own application ?

推荐答案

如果您仍然关心如何重新打开已关闭的窗口,请使用此方法:

If you are still concerned how to reopen the window that you have closed, use this method:

- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag {

[window makeKeyAndOrderFront:self];

return YES;
}

您可以使用它来处理Dock中应用程序图标的点击。

You can use this to handle clicks on the applications icon in the dock.

有关详细信息,请参阅NSApplicationDelegate协议参考。

For further information check out the NSApplicationDelegate Protocol Reference.

这是文档:

http:// developer .apple.com / library / mac /#documentation / cocoa / reference / NSApplicationDelegate_Protocol / Reference / Reference.html

希望这有帮助!

这篇关于关闭Mac应用程序(单击顶部的红色十字),然后通过单击停靠图标重新打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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