[英]Why is type always UIView when I drag and drop UIButton or UILabel to ViewController.swift file
Below is the screenshot.下面是截图。 This is the problem I face when I drag and drop either a
UILabel
or UIButton
.这是我在拖放
UILabel
或UIButton
时面临的问题。
Please help me I am a beginner and I have just started.请帮助我我是初学者,我刚刚开始。 I just added a button and a label and want to change text in label upon button click but I am facing this problem.
我刚刚添加了一个按钮和一个标签,并希望在单击按钮时更改标签中的文本,但我遇到了这个问题。
When dragging from the storyboard to the class file to create an IBOutlet
, if the containing view is selected in the navigator (as shown in your screenshot), then that will be linked to the outlet.当从故事板拖动到类文件以创建
IBOutlet
,如果在导航器中选择了包含视图(如屏幕截图所示),那么它将链接到插座。
To make sure you're connecting to the correct object either确保您连接到正确的对象
or或者
似乎您正在尝试为Label Message View 而不是Label创建一个插座,为什么它总是UIView
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.