禁用的按钮如何获得触摸? [英] How can a disabled button get touches?

查看:50
本文介绍了禁用的按钮如何获得触摸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道这怎么会发生.在我的iPhone应用程序中,在加载http请求期间,我禁用了导航栏中的按钮.但是,当我在加载完成后触摸按钮三到四次时,将调用action方法,这意味着即使禁用了按钮,也会检测到触摸,然后调用ibaction方法.

I was just wondering how can this happen. In my iPhone application during a http request loading I am disabling a button in the navigation bar. But when I touch the button three or four times the action method gets called after the loading is completed this means that even though the button is disabled the touches are detected on it and later the ibaction method is called .

那么这是例外还是有什么方法可以防止这种情况发生?

So is this exceptional or is there any way to prevent this ?

谢谢....

推荐答案

禁用UIControl不会阻止它获得触摸事件(并且您不应该在UIControl上覆盖 -touchesBegan:等无论如何).

Setting a UIControl disabled does not prevent it from getting touch events (and you shouldn't override -touchesBegan: etc on a UIControl anyway).

您应该将按钮的 userInteractionEnabled 属性设置为NO,以避免触摸事件.

You should set the button's userInteractionEnabled property to NO to avoid the touch events.

这篇关于禁用的按钮如何获得触摸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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