如何为Mac应用程序设置Kiosk模式?
问题描述:
我试图让应用程序启动在演示模式,同时禁止在Dock中,菜单栏,进程切换等我到目前为止这样的代码:如何为Mac应用程序设置Kiosk模式?
let presOptions: NSApplicationPresentationOptions =
.HideDock | // Dock is entirely unavailable. Spotlight menu is disabled.
// .AutoHideMenuBar | // Menu Bar appears when moused to.
// .DisableAppleMenu | // All Apple menu items are disabled.
.DisableProcessSwitching | // Cmd+Tab UI is disabled. All Exposé functionality is also disabled.
.DisableForceQuit | // Cmd+Opt+Esc panel is disabled.
.DisableSessionTermination | // PowerKey panel and Restart/Shut Down/Log Out are disabled.
.DisableHideApplication | // Application "Hide" menu item is disabled.
// .AutoHideToolbar |
.FullScreen
let optionsDictionary = [NSFullScreenModeApplicationPresentationOptions: presOptions]
browserWindowController.containerView.enterFullScreenMode(NSScreen.mainScreen()!, withOptions: optionsDictionary)
在.HideDock线我得到的错误:
Type of expression is ambiguous without more context
有人能帮我找到解决办法,并解释错误的含义。
同样在browserWindowController线我得到的错误:这是为什么不工作,我
Use of unresolved identifier 'browserWindowController'
有人能解释一下吗?
答
与SWIFT 2 NSApplicationPresentationOptions
必须是一个数组:
let presOptions: NSApplicationPresentationOptions = [
.HideDock, // Dock is entirely unavailable. Spotlight menu is disabled.
// .AutoHideMenuBar, // Menu Bar appears when moused to.
// .DisableAppleMenu, // All Apple menu items are disabled.
.DisableProcessSwitching, // Cmd+Tab UI is disabled. All Exposé functionality is also disabled.
.DisableForceQuit, // Cmd+Opt+Esc panel is disabled.
.DisableSessionTermination, // PowerKey panel and Restart/Shut Down/Log Out are disabled.
.DisableHideApplication, // Application "Hide" menu item is disabled.
// .AutoHideToolbar,
.FullScreen
]
至于browserWindowController
错误它只是意味着雨燕编译器不知道这个变量是什么。它可能被定义在当前使用范围之外,甚至根本没有声明。
哇,这很快。谢谢你的工作,但我仍然有一个browerWindowController行错误。你知道它是什么,甚至我应该用什么来代替线条?谢谢 – grahamcracker1234
不客气。找到你正在创建的位置'let browserWindowController = ...'它似乎超出了你想要使用变量的地方。 – Moritz
好的,谢谢,我没有在任何地方声明。我是新开发的Mac应用程序,并且只有IOS经验,所以在完全设置演示文稿选项时我完全失去了它。你能解释一下我应该用什么来代替browserWindowController这一行。 – grahamcracker1234