开发者

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 awak开发者_StackOverfloweFromNib methods of my NSWindowController class, but it flickers for a second before closing.


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

See: The Nib Object Life Cycle.


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


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.

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


open IB and uncheck "Visible at launch"

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

[window makeKeyAndOrderFront:self]


Just uncheck the "Visible at launch" option.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜