ios 无法插入新的插座连接:找不到名为类的任何信息

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29923881/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 05:49:18  来源:igfitidea点击:

Could not insert new outlet connection: Could not find any information for the class named

iosswiftxcodeinterface-builderiboutlet

提问by Ege Kaan Gürkan

I got an error on Xcode saying that there was no information about the view controller.

我在 Xcode 上收到一个错误,说没有关于视图控制器的信息。

Could not insert new outlet connection: Could not find any information for the class named

无法插入新的插座连接:找不到名为类的任何信息

Why is this happening?

为什么会这样?

Screenshot 1

截图 1

回答by Suragch

Here are some things that can fix this (in increasing order of difficulty):

以下是一些可以解决此问题的方法(按难度递增):

  • Clean the project (Product > Clean)
  • Manually paste in

    @IBOutlet weak var viewName: UIView!
    // or
    @IBAction func viewTapped(_ sender: Any) { }
    

    and control drag to it. (Change type as needed.) Also see this.

  • Completely close Xcode and restart your project.

  • Delete the Derived Data folder (Go to Xcode > Preferences> Locationsand click the gray arrow by the Derived Data folder. Then delete your project folder.)
  • Click delete on the class, remove reference (not Move to Trash), and add it back again. (see this answer)
  • 清理项目(产品 > 清理
  • 手动粘贴

    @IBOutlet weak var viewName: UIView!
    // or
    @IBAction func viewTapped(_ sender: Any) { }
    

    并控制拖动到它。(根据需要更改类型。)另请参阅

  • 完全关闭 Xcode 并重新启动您的项目。

  • 删除派生数据文件夹(转到Xcode > Preferences> Locations并单击派生数据文件夹旁边的灰色箭头。然后删除您的项目文件夹。)
  • 单击类上的删除,删除引用(而不是移到垃圾箱),然后再次添加回来。(见这个答案

回答by Stephen Paul

Or if none of the above works, type out the name of the outlet into the file first @IBOutlet weak var headerHeightConstraint: NSLayoutConstraint!and then click and drag from the outlet in the nib to the variable you just programmatically created. It should work without any of the hassle of cleaning, building, and deleting anything.

或者,如果上述方法均无效,请先在文件中输入插座的名称,@IBOutlet weak var headerHeightConstraint: NSLayoutConstraint!然后单击并从笔尖中的插座拖动到您刚刚以编程方式创建的变量中。它应该可以正常工作,而无需任何清理、构建和删除任何内容的麻烦。

回答by Akshaykumar Maldhure

Just perform the two following steps to get rid of this error

只需执行以下两个步骤即可摆脱此错误

  1. Clean project using Product > clean
  2. Run the project
  1. 使用 Product > clean 清理项目
  2. 运行项目

Now try to add the action or outlet. That's it.

现在尝试添加动作或插座。就是这样。

Happy Coding

快乐编码

回答by Joshua Dance

None of the tips in the best answer worked for me. Was going crazy. Then noticed that the Assistant Editor had somehow gotten set to Manualand I was on the ViewController.swift (Interface)instead of the ViewController.swift file.

最佳答案中的任何提示都不适合我。快疯了。然后注意到助理编辑器不知何故被设置为手动,我在ViewController.swift(接口)而不是 ViewController.swift 文件上。

Changed that and problem solved. A bit embarrassing but hey, we are all learning.

改变了,问题解决了。有点尴尬,但是嘿,我们都在学习。

enter image description here

在此处输入图片说明

回答by Almeida

Here are the steps solved for me:

以下是为我解决的步骤:

  1. Remove Class name reference from View(storyboard/xib) and save;
  2. Add Class name again and save;
  3. Clean and Build;
  1. 从 View(storyboard/xib) 中删除类名引用并保存;
  2. 再次添加类名并保存;
  3. 清洁和建造;

Done !

完毕 !

回答by Jayprakash Dubey

I had the same issue. I tired below solutions but didn't worked :

我遇到过同样的问题。我厌倦了以下解决方案,但没有奏效:

  1. Clean Project (cmd + shift + k)and even Clean Project Build (cmd + shift + alt + k)
  2. Deleted Derived dataand Module Cache content
  1. Clean Project (cmd + shift + k)乃至 Clean Project Build (cmd + shift + alt + k)
  2. Deleted Derived dataModule Cache content

Below workaround to this issue :

以下解决此问题的方法:

  1. Move to source code file and write the IBOutlet / IBActionmanually (copy paste preferred)
  1. 移至源代码文件并IBOutlet / IBAction手动编写(首选复制粘贴)

Screenshot 1

截图 1

  1. Then move to Storyboard file and Open Utiliteswindow
  2. Goto Connection Inspector
  3. Then Connect the IBOutletand IBActionwritten in source file with Interface Builder.
  1. 然后移动到 Storyboard 文件并打开Utilites窗口
  2. Connection Inspector
  3. 然后使用Interface Builder连接IBOutletIBAction写入源文件。

Screenshot 2

截图 2

回答by Vitalii

I had the same problem. I realised than in X-Code Manualitem was selected when I tried to create an outlet by control-drag

我有同样的问题。Manual当我尝试通过控制拖动创建插座时,我意识到选择了 X-Code 中的项目

enter image description here

在此处输入图片说明

After I set it to automatic it worked

在我将其设置为自动后,它起作用了

enter image description here

在此处输入图片说明

回答by KuboAndTwoStrings

I solved this problem by programmatically creating the Labels and Textfields, and then Command-Dragged from the little empty circles on the left of the code to the components on the Storyboard. To illustrate my point: I wrote @IBOutlet weak var HelloLabel: UILabel!, and then pressed Command and dragged the code into the component on the storyboard.

我通过以编程方式创建标签和文本字段解决了这个问题,然后从代码左侧的小空圆圈命令拖动到故事板上的组件。为了说明我的观点:我写了@IBOutlet weak var HelloLabel: UILabel!,然后按 Command 并将代码拖到故事板上的组件中。

回答by Ali

  1. Close the project you are working on with.
  2. Delete your project's【DerivedData】folder. (This folder may inside your project's folder, or inside
    ~/Library/Developer/Xcode/DerivedData/
    (your project)/) or somewhere else that was setup by you.
  3. restart your project.
  1. 关闭您正在处理的项目。
  2. 删除项目的【DerivedData】文件夹。(此文件夹可能在您的项目文件夹内,或
    ~/Library/Developer/Xcode/DerivedData/
    (您的项目)/内)或您设置的其他位置。
  3. 重启你的项目。

回答by Vision Mkhabela

I found an easier workaround as I this bug can be found on XCODE 9.

我找到了一个更简单的解决方法,因为我可以在 XCODE 9 上找到这个错误。

Step one go to your viewcontroller and manually write the property you want to connect as the below example, make sure you use the below format.

第一步转到您的视图控制器并手动编写您要连接的属性,如下例所示,确保使用以下格式。

@IBOutlet weak var questionsStackView: UIStackView!

@IBOutlet 弱变量问题StackView:UIStackView!

Step two go to your storyboard and connect your view or whatever your trying to connect to the property you created in step 1.

第二步转到您的故事板并连接您的视图或您尝试连接到您在第 1 步中创建的属性的任何内容。

The above will save you time of removing and cleaning derived data.

以上将节省您删除和清理派生数据的时间。