无法在Interface Builder中连接IBOutlet [英] Can't connect IBOutlet in Interface Builder
问题描述
我有一种奇怪的经历。我创建任何类型的iPhone应用程序,添加带有Xib文件的UIViewController。我可以使用控件编辑xib文件,如果我运行则看到它们呈现。现在我正在尝试向控制器添加一些IBOutlets,因此我将它们添加到.h文件中,在.m文件上进行合成。然后我转到Interface Builder连接插座。我将UILabel拖到UIView,然后我尝试连接文件所有者(我的自定义UIViewController),但是当我尝试连接到UILabel时我可以选择的是查看,这显然是错误的。所以我无法将IBOutlets连接到Interface Builder中的控件。
I'm having a weird experience. I create any type of iPhone application, add a UIViewController with Xib file. I can edit the xib file with controls and see them rendered if I run. Now i'm trying to add a few IBOutlets to the controller, so I add them to the .h file, synthesize on the .m file. Then i head over to Interface Builder to connect the outlets. I drag the UILabel to the UIView, and then i try to connect the File Owner (which my custom UIViewController), but all that i can select when i try to connect to the UILabel is "view", which is obviosly wrong. So I'm not able to connect IBOutlets to their controls in Interface Builder.
任何想法?
推荐答案
我在这个帖子中做了一些事情,我终于成功了。
I did a combination of the things in this thread and I finally had success.
在Interface builder(不是xcode)
In Interface builder (not xcode)
- 文件 - >重新加载所有类文件
- 文件 - >读取类文件(选择MyClass.h)
- 通过
a重新连接文件所有者。将类设置为MyClass
b。将视图重新连接到文件所有者的视图
现在一切都恢复正常了。很奇怪。
Everything is back to normal now. Weird.
希望这有助于解决问题; - )
Hope this helps more than it confuses ;-)
这篇关于无法在Interface Builder中连接IBOutlet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!