我正在尝试以演示模式启动应用程序,同时禁用Dock,菜单栏,进程切换等。到目前为止我有这个代码:
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行上我收到错误:
如果没有更多的上下文,表达的类型是不明确的
有人可以帮我找到解决方案并解释错误的含义。
同样在browserWindowController行上我收到错误:
使用未解析的标识符&browserWindowController'
有人可以向我解释为什么这不起作用吗?
答案 0 :(得分:2)
使用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
错误,它只是意味着Swift编译器不知道这个变量是什么。它可能已经在当前使用范围之外定义,甚至根本没有声明。
答案 1 :(得分:1)
我已经更新了Swift 4.2的代码。看看。
//Enter kiosk mode
func KisokMode(){
let presOptions: NSApplication.PresentationOptions = [
.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 = [NSView.FullScreenModeOptionKey.fullScreenModeApplicationPresentationOptions: presOptions]
TheWindowExample.contentView?.enterFullScreenMode(NSScreen.main!, withOptions: optionsDictionary)
}
TheWindowExample是您要使用信息亭模式的窗口。