Why can setPresentationOptions and LSUIElement not be used together?

Deadly 提交于 2019-12-02 20:29:20

问题


Code:

[NSApp setPresentationOptions: NSApplicationPresentationHideMenuBar | NSApplicationPresentationHideDock];

It hides Dock and MenuBar OSX.

When I add key LSUIElement into my Info.plist file and rerun my code: Dock is hidden, but MenuBar doesn't hidden.

Why? How to hide MenuBar after adding LSUIElement?


回答1:


Well, it should hide the main menu always and forever, but using LSUIElement in the plist is an older way of doing things than using both setActivationPolicy and setPresentationOptions so you might want to give [NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory] a shot instead.

The LSUIElement way of doing things didn't support changes at runtime. You're mixing old and new. Deprecate LSUIElement and use setActivationPolicy on OSX 10.9+.

There is lots of discussion along these lines. This is a good answer. I wrote an answer about how to switch to accessory mode when the user "quits" the app here and that uses the runtime functionality which LSUIElement would break. So don't use it.



来源:https://stackoverflow.com/questions/30327597/why-can-setpresentationoptions-and-lsuielement-not-be-used-together

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!