Xcode Swift:无法插入新的插座连接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48061831/
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
Xcode Swift: Could not insert new outlet connection
提问by esea123
回答by Cons Bulaquena
回答by Mathias Van Houtte
I had this issue and I searched for several days how to fix this. I tried every solution that I could find, but without any luck.
我遇到了这个问题,我搜索了几天如何解决这个问题。我尝试了我能找到的所有解决方案,但没有任何运气。
I started looking in my git history on which branch the error occurred. I found a solution after several days.
我开始查看我的 git 历史记录发生错误的分支。几天后我找到了解决方案。
I was working on a big project and I wanted to speed up my build speed and I changed some stuff in the build settings. The build setting that caused this issue was 'Swift compiler - Optimization level'. I changed the default value (No optimization) to 'Optimize for speed' and this caused the issue "Could not insert new outlet connection".
我正在做一个大项目,我想加快我的构建速度,我在构建设置中更改了一些内容。导致此问题的构建设置是“Swift 编译器 - 优化级别”。我将默认值(无优化)更改为“优化速度”,这导致了“无法插入新的插座连接”的问题。
I hope I can help others with this solution because I lost a lot of time with it.
我希望我可以用这个解决方案帮助其他人,因为我失去了很多时间。
回答by Mujahid Latif
In my case nothing worked
就我而言,没有任何效果
1) Deleting Class
1) 删除类
2) Disconnecting the @IBOutlet
2) 断开@IBOutlet
3) Manually Creating @IBOutlet Connections
3) 手动创建@IBOutlet 连接
The thing which did work was to restart XCode
有效的方法是重新启动 XCode
After restart you can easily connect them without errors
重新启动后,您可以轻松连接它们而不会出错
回答by Kathiresan Murugan
Check that ViewController is correct or not?
检查 ViewController 是否正确?
Or
或者
Clear class name in storyboard and edit again and also in class file
清除故事板中的班级名称并再次编辑以及在班级文件中
Or
或者
quit Xcode and reopen and try that
退出Xcode并重新打开并尝试
回答by claude31
Can you connect the other way, ie from the IBOutlet to the search bar ? In such a case, a clean of build border plus a reopen of the project should solve the problem.
您可以通过其他方式连接,即从 IBOutlet 连接到搜索栏吗?在这种情况下,清理构建边界加上重新打开项目应该可以解决问题。
回答by jrbm
I know it's too late to answer this question. But, I think it was because you made a change to the class name on your swift file and it hasn't been saved yet. (The file is grayed out)
我知道现在回答这个问题为时已晚。但是,我认为这是因为您对 swift 文件中的类名进行了更改,但尚未保存。(文件变灰)
My solution: Try building it (Command + B), then connect it again.
我的解决方案:尝试构建它(Command + B),然后再次连接。
回答by Chea Thim
Error? Just check the locations of UI class file(swift) and UI builder file(xib or storyboard). Best is "Relative to Group"
错误?只需检查 UI 类文件(swift)和 UI 构建器文件(xib 或故事板)的位置。最好是“相对于组”