禁用的按钮如何获得触摸?

发布于 2024-08-23 03:58:19 字数 181 浏览 12 评论 0原文

我只是想知道怎么会发生这种事。在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

走过海棠暮 2024-08-30 03:58:19

将 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文