将窗口控制器插座连接到窗口 [英] Connect Window Controller Outlet to Window

查看:132
本文介绍了将窗口控制器插座连接到窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在XCode 4中创建一个简单的模态对话框。我创建了xib,创建了NSWindowController派生类,并将其作为xib的文件所有者中的类。我遇到问题的部分是物理连接窗口出口,如问题的答案中所述:

I am trying to create a simple modal dialog in XCode 4. I have created the xib, created the NSWindowController derived class and made it the class in the File's Owner of the xib. The part I am having trouble with is physically connecting the window outlet as mentioned in the answers to questions:

5290778#5290778>如何将重点放在从NIB加载的NSWindow?

为什么我必须在10.5在NSWindowController上调用showWindow两次?

和在Apple文档中:

and in Apple documentation here:

http://开发人员。 apple.com/library/mac/#documentation/Cocoa/Conceptual/Documents/Concepts/WinControllersAndNibs.html

我理解这个概念,但我无法想象看看如何在XCode 4中实际上!我知道如何通过CTRL拖动将一个控件在xib连接到一个插座或类中的动作。

I understand the concept, but I cannot figure out how to actually do it in XCode 4! I know how to connect a control in a xib to an outlet or action in a class via CTRL-drag. I just do not know what to drag to and from in this case.

任何帮助感谢。

推荐答案

确定 - 我想出来了。

OK - I figured it out.

选择文件的所有者对象。控制 - 从那里拖动到XIB文件中的窗口。这将创建新的出口。

window outlet: In the IB Dock, select the File's Owner object. Control-drag from there to the window in the XIB file. That will create the new Outlet.

委托 outlet:
要将代理出口连接到文件的所有者, IB基座。在连接检查器中,在出口下,控制 - 从委托拖动到文件所有者此连接也可以与文件的所有者选择,只是控制拖拉从引用出口到窗口,并从弹出窗口中选择委托 。

delegate outlet: To connect the delegate outlet to the File's Owner, select the Window in the IB Dock. In the connection inspector, under Outlets, control-drag from "delegate" to "File's Owner" This connection can also be made with the File's Owner selected, just control-drag from Referencing Outlets to the window and select "delegate" from the popup.

编辑:获得此效果的最佳方法是在Window的所有者窗口和文件所有者的窗口到窗口中委托到文件的所有者出口, NSWindowController派生类先让XCode在过程中创建xib。

The best way to get this effect, delegate-to-File's Owner outlet in Window and window-to-Window outlet in File's Owner, is to create the NSWindowController-derived class first and let XCode create the xib in the process. Both outlets will be automatically created.

如果先创建了xib,并且想要将其挂接到NSWindowController派生类,那么可以通过ctrl创建outlet -d在IB中:

If the xib was created first, and you wish to hook it to a NSWindowController-derived class, then the outlets can be created via ctrl-drag in IB:


  • 要在文件所有者中创建窗口到窗口,请选择文件的所有者并从文件的所有者

  • 要在窗口中创建委托到文件的所有者销售点,请选择Window和

      ,然后在弹出窗口中选择
    • 按住Ctrl键并从窗口拖动到文件的所有者,然后在弹出窗口中选择委托。

    • -drag from delegate to File's Owner。

    这些步骤也可以 通过使用新引用出口....

    These steps can also be "inverted" by using New Referencing Outlet....

    这篇关于将窗口控制器插座连接到窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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