Are there any example on how to write full-screen apps for Mac OS X in Objective-C with Cocoa?

不打扰是莪最后的温柔 提交于 2019-12-04 16:42:55

Add the following code to the NSView you want to make fullscreen:

[view enterFullScreenMode:[NSScreen mainScreen] withOptions:nil];

It's exactly the same, the only thing you need to watch for is if you have any NSWindow specific code...

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSView_Class/Reference/NSView.html

http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=02

There is an OSX Cocoa example for many of the tutorials.

Try this:

- (void)toggleMyViewFullScreen:(id)sender
{
    if (myView.inFullScreenMode) {
      [myView exitFullScreenModeWithOptions:nil];
    } else {
      NSApplicationPresentationOptions options =
          NSApplicationPresentationHideDock |       
          NSApplicationPresentationHideMenuBar;

      [myView enterFullScreenMode:[NSScreen mainScreen] withOptions:@{
             NSFullScreenModeApplicationPresentationOptions : @(options) }];
                                                                                 }];
    }
}

You can connect this to the fullscreen menu item in the Window menu (after inserting that into your nib) but be sure to change the action that the menu item fires to your toggleMyViewFullScreen: . Or your can invoke toggleMyViewFullScreen programmatically or when your app loads.

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