以编程方式将 UIView 更改为 UIControl 的实例 [英] Changing UIView To be instance from UIControl Programmatically

查看:37
本文介绍了以编程方式将 UIView 更改为 UIControl 的实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个按钮可以将视图的类更改为 UIControl

I have a button that will change the view's class to UIControl

我已经输入了这行代码,但 Xcode 说这是一个错误

i have typed this line of code but Xcode say it is a error

-(IBAction)button:(id)sender
{

    self.view.class = [UIControl class];
}

所以伙计们,我的问题是如何以编程方式将我的视图类更改为 UIControl

So guys my question is how to change my view's class to UIControl class programmatically

推荐答案

您不能在运行时更改类类型.或者,您可以将控件设置为停止处理用户交互:

You cant change the class type at runtime. Alternatively you can set your control to stop handling user interactions:

self.userInteractionEnabled = NO;

这篇关于以编程方式将 UIView 更改为 UIControl 的实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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