Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set initial size for NSWindow

I'm trying to set an initial size for my NSWindow. First, I tried to set size using storyboard.

enter image description here

And then I tried the code below, the both don't work.

NSWindow *mainWindow = [[[NSApplication sharedApplication] windows] objectAtIndex:0];
mainWindow.titleVisibility=NSWindowTitleHidden;
NSRect frame = mainWindow.frame;
frame.size=CGSizeMake(1000, 200);
[mainWindow setFrame:frame display:YES];

I tried to check or uncheck the "Restorable" attribute. How can I set an initial size for NSWindow? Why are these not working?

like image 410
amone Avatar asked Oct 31 '22 18:10

amone


1 Answers

I found a way to set the initial window size in the storyboard editor of Xcode. Instead of setting the size of the window, you need to set it on the ViewControllers first element like this:

enter image description here

like image 177
Rene Blath Avatar answered Nov 15 '22 07:11

Rene Blath