使用Swift 3在macOS 10.12的第二个屏幕上使用NSWindow全屏显示?
我正试图在第二个屏幕上显示第二个窗口的全屏显示,尽管我仍然看到菜单栏 这是我的代码:使用Swift 3在macOS 10.12的第二个屏幕上使用NSWindow全屏显示?,swift,fullscreen,nswindow,Swift,Fullscreen,Nswindow,我正试图在第二个屏幕上显示第二个窗口的全屏显示,尽管我仍然看到菜单栏 这是我的代码: let second_screen = NSScreen.screens()?[1] let window = NSWindow(contentRect: (second_screen?.frame)!, styleMask: .fullScreen, backing: .buffered, defer: true, screen: second_screen) self.window_controller =
let second_screen = NSScreen.screens()?[1]
let window = NSWindow(contentRect: (second_screen?.frame)!, styleMask: .fullScreen, backing: .buffered, defer: true, screen: second_screen)
self.window_controller = NSWindowController(window: window)
window.collectionBehavior = .fullScreenAuxiliary
window_controller?.showWindow(self)
window.toggleFullScreen(true)
有人在这件事上运气好吗
编辑1:
我加了一行:
NSApp.presentationOptions = [.fullScreen, .hideDock, .autoHideMenuBar]
我得到这个警告:
setPresentationOptions called with NSApplicationPresentationFullScreen when there is no visible fullscreen window; this call will be ignored.
编辑2:
我改用这种方法:
视图全屏显示,但不显示内容,仅显示灰色
编辑3:
我关闭了NSFullScreenModeAllScreens,现在它可以正常工作了:
let optionsDictionary = [NSFullScreenModeApplicationPresentationOptions: NSNumber(value: presOptions.rawValue), NSFullScreenModeAllScreens: false]
现在唯一的问题是菜单栏和dock不会显示在第一个屏幕上。对于我来说,
enterFullScreenMode
似乎只有在视图“显示”之后调用时才能正常工作
如果我在
函数应用程序IDbecomeactive(u-notification:notification){/*here*/}
(或者也可以使用计时器.scheduledTimer
)中调用它,它就可以工作。的副本?在10.12尝试了所有答案,但运气不佳
let optionsDictionary = [NSFullScreenModeApplicationPresentationOptions: NSNumber(value: presOptions.rawValue), NSFullScreenModeAllScreens: false]