0

有人可以告诉我在 InterfaceBuilder 中将一组 UITextView 对象连接到 IBOutletCollection 的步骤是什么?在我的 XIB 文件(比如 myfile.xib)中,我有一排 8 个 UITextView 对象。在我的 myfile.h 文件中,我声明了一个 IBOutletCollection:

@property (nonatomic, retain) IBOutletCollection(UITextView) NSArray *textViews;

现在我想将 XIB UITextView 对象连接到 IBOutletCollection。我尝试从 XIB 中的第一个 UITextView CTRL 拖动到 FileOwner,但这并没有显示任何 IBOutlets。我试图在 FileOwner 上按 CTRL 单击(右键单击),然后弹出了一些黑色的小菜单。这显示了我的 textViews 插座集合,所以我尝试从 textViews 的小圆圈拖动到 XIB 中的 UITextView 对象,但这没有做任何事情。我在谷歌上搜索了一些关于此的信息,但我只找到了诸如“以通常的方式将你的 UITextView 连接到 IBOutletCollection”之类的语句。我不知道“通常的方式”是什么。请帮忙。

4

2 回答 2

0

Are you sure you were were dragging from the correct "little circle" to your text views, because that works fine for me.

Another way is to do it just like you connect an outlet by opening the assistant editor so you can see both the xib file and the controller's .h or .m file. Starting with no code in the controller, select the text view and control-drag from it to the area under @interface, and it should say, "Insert Outlet or Outlet Collection". When you let go, fill in the name, and then change the "connection" pull-down from "outlet" to "outlet collection". After the first one is done, control-drag from the other text views to that line of code.

于 2014-04-23T03:47:58.650 回答
0

确保将 File's Owner 的类设置为您尝试将插座集合连接到的类。打开 Identity Inspector (Ctrl + Cmd + 3) 并在框中输入您的班级名称。然后尝试再次连接插座。

于 2014-04-23T03:58:41.127 回答