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

霸气de小男生 提交于 2019-12-09 22:45:14

问题


Could someone point me to any examples on how to write full-screen apps for Mac OS X in Ojective-C with Cocoa?


回答1:


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




回答2:


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

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




回答3:


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.



来源:https://stackoverflow.com/questions/4492347/are-there-any-example-on-how-to-write-full-screen-apps-for-mac-os-x-in-objective

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