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
Could not insert new outlet connection: Could not find any information for the class named
提问by Ege Kaan Gürkan
回答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)
回答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
只需执行以下两个步骤即可摆脱此错误
- Clean project using Product > clean
- Run the project
- 使用 Product > clean 清理项目
- 运行项目
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.
改变了,问题解决了。有点尴尬,但是嘿,我们都在学习。
回答by Almeida
Here are the steps solved for me:
以下是为我解决的步骤:
- Remove Class name reference from View(storyboard/xib) and save;
- Add Class name again and save;
- Clean and Build;
- 从 View(storyboard/xib) 中删除类名引用并保存;
- 再次添加类名并保存;
- 清洁和建造;
Done !
完毕 !
回答by Jayprakash Dubey
I had the same issue. I tired below solutions but didn't worked :
我遇到过同样的问题。我厌倦了以下解决方案,但没有奏效:
Clean Project (cmd + shift + k)
and evenClean Project Build (cmd + shift + alt + k)
Deleted Derived data
andModule Cache content
Clean Project (cmd + shift + k)
乃至Clean Project Build (cmd + shift + alt + k)
Deleted Derived data
和Module Cache content
Below workaround to this issue :
以下解决此问题的方法:
- Move to source code file and write the
IBOutlet / IBAction
manually (copy paste preferred)
- 移至源代码文件并
IBOutlet / IBAction
手动编写(首选复制粘贴)
- Then move to Storyboard file and Open
Utilites
window - Goto
Connection Inspector
- Then Connect the
IBOutlet
andIBAction
written in source file with Interface Builder.
- 然后移动到 Storyboard 文件并打开
Utilites
窗口 - 去
Connection Inspector
- 然后使用Interface Builder连接
IBOutlet
并IBAction
写入源文件。
回答by Vitalii
回答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
- Close the project you are working on with.
- 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. - restart your project.
- 关闭您正在处理的项目。
- 删除项目的【DerivedData】文件夹。(此文件夹可能在您的项目文件夹内,或
~/Library/Developer/Xcode/DerivedData/
(您的项目)/内)或您设置的其他位置。 - 重启你的项目。
回答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.
以上将节省您删除和清理派生数据的时间。