如何关闭窗口(卸载NIB)? [英] How to close a window (unload a NIB)?

查看:109
本文介绍了如何关闭窗口(卸载NIB)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义 NSWindowController 子类,在初始化期间加载NIB文件,如下所示:

I have a custom NSWindowController subclass that loads a NIB file during initialization like this:

self = [super initWithNibNamed:@"myNib"];
if (self != nil) {
    [self window];
}

nib包含一些自定义视图和一些其他控件。 NSWindowController 是文件的所有者,至少有一个视图甚至绑定到它。

The nib contains some custom views and some other controls. The NSWindowController is the file's owner and at least one of the views even binds to it.

我必须做关闭和释放那个窗口吗?

Simply, what do I have to do to close and release that window? I spend the whole day trying to figure that out and I am still clueless.

推荐答案

你不能卸载一个笔尖; 加载它只是将存档在其中的对象归档。这不是一个无限期持续的状态;这是一个短暂的行动。一旦你取消了对象的存档,那么它来自何处。

You don't unload a nib; "loading" it is simply unarchiving the objects that are archived within it. That's not a state that persists indefinitely; it's a momentary action. Once you've unarchived the object, it doesn't matter where it came from.

如果你不在窗口控制器中,则:

If you were not in a window controller, then:

  • To close a window, you would send it a close message.
  • To close and release a window, you would need to either have its releasedWhenClosed property turned on (you can do this in IB) before you send it a close message, or send it a release message after the close message.

窗口控制器,只需向您自己发送关闭讯息

But since you are in a window controller, just send yourself a close message.

另请参阅窗口关闭行为基于文档的应用程序概述(基于文档的应用程序是窗口控制器的主要用户)。

See also "Window Closing Behavior" in the Document-Based Applications Overview (document-based apps being the main users of window controllers).

这篇关于如何关闭窗口(卸载NIB)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆