开发者

Cocoa - dual full screen mode?

开发者 https://www.devze.com 2023-03-01 05:37 出处:网络
I\'m开发者_Go百科 an ObjC / Cocoa novice. I have a WebView which I wish to display full screen across two screens side-by-side.

I'm开发者_Go百科 an ObjC / Cocoa novice.

I have a WebView which I wish to display full screen across two screens side-by-side.

Using NSView enterFullScreenMode with the NSFullScreenModeAllScreens option I can make my app go full screen, but the WebView only fills my left-hand primary display - the secondary (right hand) display stays black.

Is it possible to make the WebView fill both screens?


I found the answer myself:

NSDictionary *opts = [NSDictionary dictionaryWithObjectsAndKeys:
      [NSNumber numberWithBool:YES], NSFullScreenModeAllScreens,
       nil];

NSView *view = [window contentView];
[view enterFullScreenMode:[NSScreen mainScreen] withOptions:opts];

NSRect frame = [view.window frame];
frame.size.width *= 2;
[view.window setContentSize:frame.size];

The last line is the important one - it's necessary to set the size of view.window rather than the window property of the application delegate. For reasons I don't yet understand those don't appear to be the same thing.

0

精彩评论

暂无评论...
验证码 换一张
取 消