2015-09-27 166 views
1

我試圖讓應用程序啓動在演示模式,同時禁止在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'

有人能解釋一下嗎?

回答

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錯誤它只是意味着雨燕編譯器不知道這個變量是什麼。它可能被定義在當前使用範圍之外,甚至根本沒有聲明。

+0

哇,這很快。謝謝你的工作,但我仍然有一個browerWindowController行錯誤。你知道它是什麼,甚至我應該用什麼來代替線條?謝謝 – grahamcracker1234

+0

不客氣。找到你正在創建的位置'let browserWindowController = ...'它似乎超出了你想要使用變量的地方。 – Moritz

+0

好的,謝謝,我沒有在任何地方聲明。我是新開發的Mac應用程序,並且只有IOS經驗,所以在完全設置演示文稿選項時我完全失去了它。你能解釋一下我應該用什麼來代替browserWindowController這一行。 – grahamcracker1234

相關問題