Cocoa 应用程序模板 - MainMenu.xib - 主窗口

发布于 2024-09-10 05:18:55 字数 255 浏览 0 评论 0原文

当您在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

完美的未来在梦里 2024-09-17 05:18:55

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 called Visible at launch under the heading Behavior.
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 to IBOutlets when it loads a nib... it can do whatever it wants.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文