无法在 Interface Builder (Xcode 5) 中创建到子视图的插座连接 [英] Cannot create outlet connections to subviews in Interface Builder (Xcode 5)

查看:17
本文介绍了无法在 Interface Builder (Xcode 5) 中创建到子视图的插座连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这似乎是其他一些问题的重复,但答案对我不起作用.

I know this appears to be a duplicate of some other questions, but the answers are not working for me.

  1. 我创建了一个单视图应用.
  2. 在故事板中,我向主视图添加了一个子视图.
  3. 我的主视图上有一个标签,子视图上有另一个标签.
  4. 我创建了一个 UIView 类型的类并将其添加为子视图的自定义类.
  5. 我可以按住 ctrl 键并拖动主视图上的标签到主视图控制器类.但是,当我尝试将子视图上的标签按 ctrl 拖动到自定义类时,我无法建立连接.
  6. 我什至输入了属性信息并尝试手动建立连接,但无济于事.

最新版本的 Xcode 的 Interface Builder 发生了一些变化.有人可以告诉我我缺少什么吗?这里实际上没有代码.我只是在测试尝试使用自定义类将插座连接到子视图.

Things have changed a bit in the latest version of Xcode's Interface Builder. Can somebody tell me what I am missing? There is literally no code here. I am just testing trying to connect outlets to a subview with a custom class.

第一张图显示我已经设置了自定义类并添加了一个属性,但我无法建立连接.

The first image shows that I have set up the custom class and added a property but I cannot make the connection.

第二张图显示了主视图标签连接在主视图的控制器中.

The second image shows the main view label is connected in the main view's controller.

第三张图显示子视图的标签没有出口连接.

The third image shows that there are no outlet connections for the subview's label.

推荐答案

您可以在自定义视图子类的@interface中手动编写IBOutlet属性声明,并且假设你已经在IB中定义了你的子视图的基类,那么你可以从代码中的outlet圆拖回场景中的控件.

You can manually write the IBOutlet property declaration in the @interface of the custom view subclass, and assuming you've defined the base class of your subview in IB, then you can drag from the outlet circle in the code back to the control in the scene.

或者,正如您所指出的,Warren Burton 在他对另一个问题的回答中建议了这种技术和另一种技术,Can't Wire到 IB 中的子视图.

Or, as you point out, Warren Burton suggested both this technique and another in his answer to this other question, Can't Wire to Subview in IB.

这篇关于无法在 Interface Builder (Xcode 5) 中创建到子视图的插座连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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