Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Cocoa, how do you hide a window when the application launches?

Specifically, I want to create a new NSWindow in IB in MainMenu.xib, but I don't want that to be open when the application launches. I tried doing close: and orderOut: in both the init and awakeFromNib methods of my NSWindowController class, but it flickers for a second before closing.

like image 520
zekel Avatar asked Jan 14 '10 18:01

zekel


5 Answers

That's controlled by the "Visible at launch time" checkbox in the window inspector in interface builder.

See: The Nib Object Life Cycle.

like image 165
Seth Avatar answered Nov 19 '22 15:11

Seth


Open Window Attributes in IB and uncheck "Visible at launch"

like image 37
vaddieg Avatar answered Nov 19 '22 13:11

vaddieg


When working with Storyboards like me, be sure to also Uncheck the "Is initial Controller" Checkbox at the "Window Controller Attributes" tab. Because that Checkbox will cause the Window to always display and Ignore the "Visible at launch" Checkbox.

Window Controller Attributes

like image 5
Werner Avatar answered Nov 19 '22 15:11

Werner


open IB and uncheck "Visible at launch"

Then, use the following code in order to show it:

[window makeKeyAndOrderFront:self]
like image 2
Huynh Inc Avatar answered Nov 19 '22 13:11

Huynh Inc


Just uncheck the "Visible at launch" option.

like image 1
Chuck Avatar answered Nov 19 '22 13:11

Chuck