在 Cocoa 中启动后停用代理应用程序

发布于 2024-08-11 05:09:22 字数 188 浏览 1 评论 0原文

在调用 applicationDidFinishLaunching: 委托方法后,应该调用什么方法来停用应用程序?或者也许有更好的地方可以做到这一点? NSApplicationdeactivate 方法的文档说我不应该直接调用这个方法,因为 AppKit 更知道如何停用东西。

What method should be called to deactivate an app right after it's launch in applicationDidFinishLaunching: delegate method has been called? Or maybe there is a better place to do that? The documentation for deactivate method for NSApplication says that I shouldn't call this method directly since AppKit knows better how to deactivate stuff.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

终难愈 2024-08-18 05:09:22

也许使用 -[NSApplication hide:] 会起作用,或者可能使用 -[NSRunningApplication activateWithOptions:] 激活另一个应用程序(仅限 10.6)。但是,我预计使用 deactivate: 不会出现很多问题。

Maybe using -[NSApplication hide:] would work, or perhaps activate another app using -[NSRunningApplication activateWithOptions:] (10.6 only, tho). However, I don't foresee many problems with using deactivate:.

吾性傲以野 2024-08-18 05:09:22

目前尚不清楚您想要实现什么目标。

您可以使用 -hide: 停用您的应用程序。如果它确实满足您的需要,我也会毫不犹豫地使用 -deactivate 。只是正常应用程序不会显式地自行停用;我认为文档就是这么说的。

但是,如果您在 Info.plist 中设置 LSUIElement,您的应用程序在启动时不应变为活动状态;它也不会有菜单栏或停靠栏图标。

It's not clear what you're trying to achieve.

You can use -hide: to deactivate your app. I also wouldn't hesitate using -deactivate if it actually does what you need. It's just that normal applications do not explicitly deactivate themselves; I think that's what the documentation is saying.

However, if you set LSUIElement in Info.plist your application should not become active when launched; it also won't have a menu bar or dock icon.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文