Reputation: 10626
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
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
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...
Upvotes: 6
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