zekel
zekel

Reputation: 9457

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.

Upvotes: 7

Views: 3363

Answers (5)

Saeverix
Saeverix

Reputation: 397

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

Upvotes: 5

Giau Huynh
Giau Huynh

Reputation: 2140

open IB and uncheck "Visible at launch"

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

[window makeKeyAndOrderFront:self]

Upvotes: 2

Chuck
Chuck

Reputation: 237010

Just uncheck the "Visible at launch" option.

Upvotes: 1

Seth
Seth

Reputation: 46413

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

See: The Nib Object Life Cycle.

Upvotes: 14

vaddieg
vaddieg

Reputation: 626

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

Upvotes: 6

Related Questions