无法将IBOutlet从storyboard连接到UIView子类 [英] Unable to connect IBOutlet from storyboard to UIView subclass

查看:419
本文介绍了无法将IBOutlet从storyboard连接到UIView子类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以右键单击并从我的自定义UIView子类文件拖动到storyboard元素以连接它们,但无法通过其他方式执行此操作。我相信这是一个Xcode错误。我能做些什么来解决这个问题吗?这不是它第一次发生而且很烦人。

I am able to right-click and drag from my custom UIView subclass file to the storyboard elements to connect them, but unable to do so the other way around. I believe this is an Xcode bug. Is there anything that I can do to fix this? This is not the first time that it happen already and its annoying.

我已经多次尝试清理和重启Xcode而没有运气。

I already tried cleaning and restarting Xcode several times with no luck.


这不起作用(右键单击故事板到Swift文件)

This does not work (Right clicking from the storyboard to Swift file)


这个工作(右键从swift文件的IBAction到故事板)

This works (Right clicking from swift file's IBAction to storyboard)

顺便说一下,我在Swift中使用Xcode 8.1 3.0。

Btw, I am using Xcode 8.1 with Swift 3.0.

更新:我不是在寻找如何连接IBOutlets / IBActions的答案,因为正如我上面提到的那样(以及截图中),我已经能够连接它们,应用程序运行正常。问题更多的是为什么Xcode不允许我从Storyboard> Swift文件连接,但让我从Swift文件> Storyboard这样做。如果这个问题具有误导性,我很抱歉。

UPDATE: I'm not looking for an answer on how to connect IBOutlets/IBActions, because as I mentioned in question above (and also in the screenshots), I am already able to connect them and the app is running fine. The question is more on WHY Xcode wouldn't let me connect from Storyboard > Swift file, but letting me to do so from Swift file > Storyboard. I'm sorry if the question is misleading.

推荐答案

在尝试了一些给定的解决方案后,最终工作的是重启我的的MacBook。这似乎是XCode方面的一个错误。哦,好吧。

After trying some of the given solution what finally worked is by restarting the my macbook. It seems like a bug on XCode's side. Oh well.

这篇关于无法将IBOutlet从storyboard连接到UIView子类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆