如何将NSApplicationPresentationOptions
转换为AnyObject?
? as
在这里不起作用。
我想打电话:
func enterFullScreenMode(_ screen: NSScreen, withOptions options: [NSObject: AnyObject]?) -> Bool
我有:
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)
这给了我最后一行的错误:
Cannot invoke 'enterFullScreenMode' with an argument list of type '(NSScreen, with Options: [String : NSApplicationPresentationOptions])'
答案 0 :(得分:1)
根据documentation,相应的值为
键
NSFullScreenModeApplicationPresentationOptions
是NSNumber
的实例,包含无符号整数值NSApplicationPresentationOptions
,因此这应该有效:
let optionsDictionary = [NSFullScreenModeApplicationPresentationOptions :
NSNumber(unsignedLong: presOptions.rawValue)]