为什么不能将setPresentationOptions和LSUIElement一起使用? [英] Why can setPresentationOptions and LSUIElement not be used together?

查看:105
本文介绍了为什么不能将setPresentationOptions和LSUIElement一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码:

[NSApp setPresentationOptions: NSApplicationPresentationHideMenuBar | NSApplicationPresentationHideDock];

它隐藏了Dock和MenuBar OSX.

It hides Dock and MenuBar OSX.

当我将键LSUIElement添加到Info.plist文件中并重新运行代码时:Dock隐藏,但MenuBar没有隐藏.

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

为什么? 添加LSUIElement后如何隐藏MenuBar?

Why? How to hide MenuBar after adding LSUIElement?

推荐答案

好吧,它应该永远隐藏主菜单,但是在plist中使用LSUIElement是较旧的方法而不是同时使用setActivationPolicysetPresentationOptions,因此您可能想给[NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory]做个尝试.

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.

LSUIElement的工作方式在运行时不支持更改.您正在混合新旧.在OSX 10.9+上弃用LSUIElement并使用setActivationPolicy.

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.

这篇关于为什么不能将setPresentationOptions和LSUIElement一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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