Cocoa 应用程序模板 - MainMenu.xib - 主窗口
当您在 Xcode 中创建新应用程序时,它会自动创建 AppDelegate 和 MainMenu.xib。后者还包含应用程序主窗口,该窗口作为 IBOutlet 链接到 AppDelegate。
我试图做的是,使用来自不同 xib 文件的 MainWindow。然而,我绝对无法阻止 Cocoa 显示它首先创建的第一个窗口,即使我删除了 IBOutlet 链接并在源文件中将其注释掉等等......
希望有人可以解释这一点,因为它已经困扰我一段时间了......
When you create a new application in Xcode, it automatically creates a AppDelegate and a MainMenu.xib. The latter also contains the application main window, which is linked to the AppDelegate as an IBOutlet.
What I tried to do is, use a MainWindow from a different xib-file. However, there's absolutely nothing I can do to prevent Cocoa from showing the first window it created in the first place, even if I remove the IBOutlet link and comment it out in the source file and what not...
Hope someone can explain this, as it has been bugging me for a while now...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
XIB 中的窗口是否在启动时显示不由显式代码控制,而是由 XIB 中窗口“冻干”的状态控制。
更具体地说,在 Interface Builder 中的
NSWindow
检查器中,您可以在Behavior
标题下找到名为Visible at launch
的选项。当 Cocoa 系统加载一个笔尖并遇到一个带有此位的窗口时,它只会将其显示在屏幕上。它与您是否有
IBOutlet
无关。你看,Cocoa 系统在加载笔尖时将 UI 对象设置为 IBOutlet...它可以做任何它想做的事情。Whether or not a window in a XIB is shown at launch is not controlled by an explicit code, but instead controlled by the state of the window "freeze-dried" in the XIB.
More concretely, in an inspector of an
NSWindow
in the Interface Builder, you have the option calledVisible at launch
under the headingBehavior
.When the Cocoa system loads a nib and encounters a window with this bit on, it just shows it on the screen. It's independent of whether you have
IBOutlet
or not. You see, it's also the Cocoa system which sets UI objects toIBOutlet
s when it loads a nib... it can do whatever it wants.