在运行时从dock添加/删除应用程序图标? [英] Add/remove application icon from dock at runtime?
问题描述
有没有一个公共的Apple API,它允许你在运行时删除应用程序的dock图标?
我试图通过NSApplication的dockTile替换一个零大小的空视图,但这只是擦除dock图标,而不回收其空间和启动指示器。我还知道应用程序的info.plist中的LSUIElement参数,但此值仅在启动时评估。它不是运行时参数。
Is there a public Apple API which allows you to remove an application's dock icon at runtime? I have tried substituting an empty view with zero size via NSApplication's dockTile, but that simply erases the dock icon without reclaiming its space and launch indicator. I also know about the LSUIElement parameter in an application's info.plist, but this value is only evaluated on launch. It is not a runtime parameter.
推荐答案
编辑
EDIT
您可以调用setActivationPolicy:NSApplicationActivationPolicyProhibited再次隐藏dock-icon
You can call setActivationPolicy:NSApplicationActivationPolicyProhibited to hide dock-icon again – user1592530 Sep 18 '12 at 14:21
这是一个单向的街道:你可以设置你的应用程序NSUIElement隐藏dock图标,然后调用 [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
在dock中显示它,但一旦它在那里你不能删除它。因此,您可以使dock图标成为用户可配置的,但您必须重新启动应用才能隐藏图标。
It's a one way street: You can set your app to NSUIElement to hide the dock icon, then call [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
to show it in the dock, but once it's there you can't remove it. So you could make the dock icon user-configurable, but you'd have to relaunch the app to hide the icon.
这篇关于在运行时从dock添加/删除应用程序图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!