开发者

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

开发者 https://www.devze.com 2022-12-16 22:23 出处:网络
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开发者

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

精彩评论

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

关注公众号