How to set up Kiosk Mode for Mac apps?

半腔热情 提交于 2019-12-04 19:21:57

With Swift 2 NSApplicationPresentationOptions has to be an array:

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
]

As for the browserWindowController error it simply means that the Swift compiler doesn't know what this variable is. It may have be defined outside the scope of its current usage or even not declared at all.

I have updated the code for swift 4.2. Check it out.

//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 is the window in which you want to work with kiosk mode.

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