【问题标题】:Why can setPresentationOptions and LSUIElement not be used together?为什么 setPresentationOptions 和 LSUIElement 不能一起使用?
【发布时间】:2015-05-19 13:48:53
【问题描述】:

代码:

[NSApp setPresentationOptions: NSApplicationPresentationHideMenuBar | NSApplicationPresentationHideDock];

它隐藏了 Dock 和 MenuBar OSX。

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

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

【问题讨论】:

    标签: objective-c macos user-interface nsapplication


    【解决方案1】:

    好吧,它应该永远永远隐藏主菜单,但是在 plist 中使用 LSUIElement 是一种比同时使用 setActivationPolicysetPresentationOptions 更老的方式,所以你可能想给[NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory] 一个机会。

    LSUIElement 的处理方式不支持在运行时进行更改。你在混合新旧。在 OSX 10.9+ 上弃用 LSUIElement 并使用 setActivationPolicy

    有很多关于这些方面的讨论。 This is a good answer。我写了一个关于当用户“退出”应用程序here 并使用LSUIElement 会中断的运行时功能时如何切换到附件模式的答案。所以不要使用它。

    【讨论】:

      猜你喜欢
      • 2020-04-05
      • 1970-01-01
      • 1970-01-01
      • 2022-12-23
      • 2014-10-05
      • 1970-01-01
      • 2018-03-09
      • 2021-06-14
      • 2012-10-09
      相关资源
      最近更新 更多