[英]How to connect an IBOutlet to an NSTextView
Unlearned programmer here. 这里是未经学习的程序员。 Last time I used a NSTextView I was able to do it by adding a class to my xib file with all my outlets declared as such:
上次使用NSTextView时,可以通过向我的xib文件中添加一个类,并声明所有我的出口的方式来做到这一点:
@interface Fusebox : NSObject
{
IBOutlet id object1;
IBOutlet id object2;
....
}
Now I am trying to code my interface properly, using the application delegate because Xcode 5 does adding a separate class file differently, if at all. 现在,我尝试使用应用程序委托对接口进行正确编码,因为Xcode 5确实添加了单独的类文件(如果有的话)。 I attempted to have Xcode's IB create the property of a NSTextView.
我试图让Xcode的IB创建NSTextView的属性。 But it wont creates this:
但它不会创建此:
@property (weak) IBOutlet NSScrollView *results;
instead of what I need, which I think is this: 而不是我所需要的,我认为是这样的:
@property (weak) IBOutlet NSTextView *results;
An NSScrollView is completely useless for my purposes of outputting formatted (mainly line breaks) strings. 对于我输出格式化(主要是换行符)字符串的目的而言,NSScrollView完全没有用。 When i try to hand code it as a NSTextView, it wont let me connect the outlet, only bind it.
当我尝试将其编码为NSTextView时,它不会让我连接插座,而只能将其绑定。 I am grabbing on a text view object from the library in the interface builder, so what am i doing wrong?
我正在从接口构建器中的库中抓取文本视图对象,所以我在做什么错呢?
I think you aren't actually hitting the NSTextView - by default, it's imbedded in an NSScrollView. 我认为您实际上并没有点击NSTextView-默认情况下,它已嵌入NSScrollView中。 Xcode probably thinks you're trying to connect the outlet to the scrollview.
Xcode可能认为您正在尝试将插座连接到scrollview。
Try expanding the left pane of Interface Builder and connect the outlet to the sidebar: 尝试展开Interface Builder的左窗格,然后将插座连接到侧边栏:
Right-click-dragging from that highlighted row above to the code gives the expected result: 右键单击从上面突出显示的行到代码,可以得到预期的结果:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.