如何在 Xcode 4 的 IB 中以图形方式添加自定义 UIControl 子类? [英] How can I add custom UIControl subclasses graphically in IB in Xcode 4?

查看:21
本文介绍了如何在 Xcode 4 的 IB 中以图形方式添加自定义 UIControl 子类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 Matthijs Hollemans 的 MHRotaryKnob 控件在我的 iOS 5 应用程序中.我在 Xcode 4.2 中使用故事板.MHRotaryKnob 作为 UIControl 的子类实现.

I want to use Matthijs Hollemans' MHRotaryKnob control in my iOS 5 app. I am using a storyboard in Xcode 4.2. MHRotaryKnob is implemented as a subclass of UIControl.

我无法复制他提供的示例,因此无法将控件添加到我的应用程序视图中.在该示例中,他的 XIB 包含一个视图,其中添加了一个 MHRotaryKnob 实例作为自定义控件.它加载并运行良好,但我无法在 Xcode 中为自己执行此操作.我已经尝试添加各种 UIControl 子类并在 Identity Inspector 中更改它们的类,但 Xcode 一直在更改它们.

I'm unable to replicate the example he provides and thus unable to add the control to my app's view. In the example, his XIB contains a view with an instance of MHRotaryKnob added to it as a custom control. It loads and runs fine but I can see no way in Xcode to do this for myself. I've tried adding every kind of UIControl subclass and changing their class in the Identity Inspector, but Xcode keeps changing them right back.

有什么想法吗?

谢谢

推荐答案

答案是将 UIView 添加到视图并在 Identity Inspector 中更改其类,而不是尝试使用按钮或其他 UIControl 来执行此操作.

The answer is to add a UIView to the view and change its class in the Identity Inspector, rather than trying to do that with buttons or other UIControls.

这篇关于如何在 Xcode 4 的 IB 中以图形方式添加自定义 UIControl 子类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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