NSWindowController 上的 windowDidLoad windowWillLoad 从未调用过
我正在使用以下代码创建一个窗口:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您真的意味着
self
(从您的代码中不清楚self
到底是什么)是 TimelogWindow.nib 的所有者吗?通常,窗口控制器是 nib 文件的所有者。尝试替换为
,以便新创建的
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 isself
) to be the owner of TimelogWindow.nib? It is usually the window controller that’s the owner of the nib file. Try replacingwith
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 typeTimelogWindowController
, and that File’s Ownerwindow
outlet is connected to the window object.