Is there a way to create a NSWindow into fullscreen mode? NSWindow has the ToggleFullscreen: selector but then it creates the window normally and animates it to the fullscreen version which isn't what I want. Any other way of doing it?
Asked
Active
Viewed 5,006 times
2 Answers
4
First find the screen size
NSRect screenRect;
NSArray *screenArray = [NSScreen screens];
unsigned screenCount = [screenArray count];
unsigned index = 0;
for (index; index < screenCount; index++)
{
NSScreen *screen = [screenArray objectAtIndex: index];
screenRect = [screen visibleFrame];
}
screenRect
contain Screen size, now creat a window and set NSWindow
size to screen size.
unsigned int styleMask = NSTitledWindowMask
| NSMiniaturizableWindowMask;
myWindow = [NSWindow alloc];
myWindow = [myWindow initWithContentRect: screenRect
styleMask: styleMask
backing: NSBackingStoreBuffered
defer: NO];
[myWindow setTitle: @"This is a test window"];

Parag Bafna
- 22,812
- 8
- 71
- 144
-
Doesn't this just maximised the window, not put it into Fullscreen mode? – AndyTang Dec 01 '11 at 09:40
-
Refer http://cocoadevcentral.com/articles/000028.php and http://stackoverflow.com/questions/401240/display-os-x-window-full-screen-on-secondary-monitor-using-cocoa – Parag Bafna Dec 06 '11 at 05:03
3
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSRect frame=[NSScreen mainScreen].frame ;
[self.window setFrame:frame display:YES animate:YES];
}
this will open window in full screen

kleopatra
- 51,061
- 28
- 99
- 211

user3122525
- 31
- 1
-
1Great, but how to set-up an app to launch into full-screen using storyboards? – Olie Jul 02 '14 at 04:00