简体   繁体   English

为什么当我将 UIButton 或 UILabel 拖放到 ViewController.swift 文件时类型总是 UIView

[英]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 .这是我在拖放UILabelUIButton时面临的问题。

在此处输入图片说明

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确保您连接到正确的对象

  • Select it first by clicking on it, either in the navigator or on the storyboard itself首先通过在导航器或故事板本身上单击来选择它

or或者

  • Drag directly from the navigator直接从导航器拖动

似乎您正在尝试为Label Message View 而不是Label创建一个插座,为什么它总是UIView

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从Main.storyboard拖放到ViewController.swift时,我无法更改连接和对象 - I can't change connection and object when drag and drop from Main.storyboard to ViewController.swift 无法控制拖动到ViewController.swift - Cannot Control-Drag into ViewController.swift 什么是ViewController.swift(接口)文件 - 在Counterparts中 - What is the ViewController.swift (Interface) file for - in Counterparts 在ViewController.swift和segue中分配给UIButton的属性在Simulator上有效,但在Device上无效 - Properties assigned to UIButton in ViewController.swift and segue works on Simulator but not on Device 在目标C文件中导入ViewController.swift - Import ViewController.swift in Objective C file file viewController.swift是忽略导入的模块“coreData”的一部分 - file viewController.swift is part of module “coreData” ignoring import 如何在 Storyboard 中将 ViewController.swift 连接到 ViewController? - How to connect ViewController.swift to ViewController in Storyboard? Xcode从viewcontroller.swift跳转到storyboard - Xcode jump from viewcontroller.swift to storyboard 拖动UIButton时UIView更改框架 - UIView change frame when drag UIButton Xcode:在 ViewController.swift 中禁用视图的旋转 - Xcode: Disable rotation for a view in the ViewController.swift
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM