NSWindowController 上的 windowDidLoad windowWillLoad 从未调用过

发布于 2024-10-15 06:14:35 字数 305 浏览 0 评论 0原文

我正在使用以下代码创建一个窗口:

if(hudWindow == nil)
    hudWindow = [[TimelogWindowController alloc] initWithWindowNibName:@"TimelogWindow" owner: self];
[hudWindow showWindow: self];

窗口显示正确,但是 TimelogWindowController 的 windowDidLoad 和 windowWillLoad 方法永远不会被调用。我已经设置了委托,还有什么问题吗?

I am creating a window using the following code:

if(hudWindow == nil)
    hudWindow = [[TimelogWindowController alloc] initWithWindowNibName:@"TimelogWindow" owner: self];
[hudWindow showWindow: self];

the window displays correctly, however the TimelogWindowController's windowDidLoad and windowWillLoad methods are never called. I have set te delegate, what else could be the problem??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

待"谢繁草 2024-10-22 06:14:35

您真的意味着 self (从您的代码中不清楚 self 到底是什么)是 TimelogWindow.nib 的所有者吗?通常,窗口控制器是 nib 文件的所有者。尝试替换

hudWindow = [[TimelogWindowController alloc]
    initWithWindowNibName:@"TimelogWindow" owner: self];

hudWindow = [[TimelogWindowController alloc]
    initWithWindowNibName:@"TimelogWindow"];

,以便新创建的 TimelogWindowController 实例成为该 nib 文件的所有者,确保 TimelogWindow.nib 中的 File's Owner 设置为 TimelogWindowController 类型,并且该 File's所有者window插座连接到窗口对象。

Do you really mean self (it is not clear from your code what exactly is self) to be the owner of TimelogWindow.nib? It is usually the window controller that’s the owner of the nib file. Try replacing

hudWindow = [[TimelogWindowController alloc]
    initWithWindowNibName:@"TimelogWindow" owner: self];

with

hudWindow = [[TimelogWindowController alloc]
    initWithWindowNibName:@"TimelogWindow"];

so that the newly created TimelogWindowController instance becomes the owner of that nib file, make sure File’s Owner in TimelogWindow.nib is set as of type TimelogWindowController, and that File’s Owner window outlet is connected to the window object.

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