[英]How to add IBOutlet of a NSTextField in a custom View correctly in macOS?
I try to create an outlet from a NSTextView
, which is a subview of my NSView
derived custom class called GeneralView
. 我尝试从
NSTextView
创建插座,这是我的NSView
派生自定义类(称为GeneralView
)的子视图。 I want to connect this outlet to my GeneralView
class but Xcode
doesn't like it. 我想将此插座连接到我的
GeneralView
类,但Xcode
不喜欢它。 I get the following screen: 我得到以下屏幕:
In this image, I want to connect an @IBOutlet
from the NSTextField
that contains '0000' to 'tfLiid' in GeneralView. 在此图像中,我想将
@IBOutlet
从包含'0000'的NSTextField
连接到@IBOutlet
中的'tfLiid'。
It only works if I create a @IBOutlet
to the ViewController
. 仅当我为
ViewController
创建一个@IBOutlet
,它才有效。 But I have like more than 50 views (textfields, progress bars, checkboxes and so on...) I need to update, so I want to split those views in 3 parent views and keep the ViewController clean by holding only the 3 parent (or group) views. 但是我需要更新50多个视图(文本字段,进度条,复选框等...),因此我想将这些视图拆分为3个父视图,并通过仅保留3个父视图来保持ViewController的干净(或组)视图。
The image below makes you understand more of what I tried to achieve (I hope). 下图使您更多地了解了我想要实现的目标(希望如此)。
I just don't know how to get this done right in Xcode, it's not a programming problem. 我只是不知道如何在Xcode中正确完成此操作,这不是编程问题。 Thank you.
谢谢。
I found a solution, just by experimenting trying out. 我只是通过尝试尝试找到了解决方案。 I just couldn't let it go.
我就是放不下。 Anyway, you have to drag from the little @IBOutlet circle (on the line number) to the view you want to connect it to.
无论如何,您都必须从@IBOutlet小圆圈(在行号上)拖动到要将其连接到的视图。 I don't know why the other way around doesn't work, there must be a reason for it.
我不知道为什么其他方法不起作用,这一定有原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.