Roman Kagan
Roman Kagan

Reputation: 10626

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

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

Upvotes: 2

Views: 4720

Answers (3)

Joel
Joel

Reputation: 2295

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.

Upvotes: 0

hauntsaninja
hauntsaninja

Reputation: 999

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

Upvotes: 6

EnabrenTane
EnabrenTane

Reputation: 7466

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

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

Upvotes: 2

Related Questions