禁用的按钮如何获得触摸?
我只是想知道怎么会发生这种事。在我的 iPhone 应用程序中,在 http 请求加载期间,我禁用了导航栏中的按钮。但是,当我触摸按钮三到四次时,加载完成后会调用操作方法,这意味着即使按钮被禁用,也会检测到触摸,然后调用 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 ?
Thanks ....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将 UIControl 设置为禁用并不会阻止它获取触摸事件(并且无论如何您都不应该在 UIControl 上覆盖
-touchesBegan:
等)。您应该将按钮的 userInteractionEnabled 属性设置为 NO 以避免触摸事件。
Setting a UIControl disabled does not prevent it from getting touch events (and you shouldn't override
-touchesBegan:
etc on a UIControl anyway).You should set the button's
userInteractionEnabled
property to NO to avoid the touch events.