随机错过一次点击

发布于 2024-08-28 01:19:41 字数 424 浏览 2 评论 0原文

我有以下代码片段

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

    UITouch *touch = [touches anyObject];
    NSUInteger numberTaps = [touch tapCount];

    // Tapping
    if (numberTaps > 0) {
       // do something
    }

...

上面的代码基本上检测小图像上的单击(宽度 = 18 和高度 = 36)。它在 90% 的时间内都能检测到单次点击。

但有时它会错过它(随机地)。我必须点击几次才能让它按下一次。

我做错了什么或错过了什么,才能始终如一地 100% 检测到单次点击?

I have the following code snippets

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

    UITouch *touch = [touches anyObject];
    NSUInteger numberTaps = [touch tapCount];

    // Tapping
    if (numberTaps > 0) {
       // do something
    }

...

The above code basically detects a single tap on a small image (width = 18 and height = 36). It works 90% of the time detecting a single tap.

But it sometime misses it (randomly). I have to tap several times before it picks up the single tap.

What did I do wrong or miss so I could consistently detect the single tap 100%?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

倾城月光淡如水﹏ 2024-09-04 01:19:41

您可能错过了点击,因为您的手指不够准确,无法始终点击硬件上的正确位置。我的应用程序中有一些可以点击的小图像,但我经常错过它们。尝试将图像放大以验证它是否始终有效。您可以人为地使图像变大,并在其周围留有空白,以使击球更加准确。

It is possible you are missing the tap because your finger isn't accurate enough to always hit the proper place on the hardware. I have small images in my app which can be tapped, and I often miss them. Try making the image larger to verify if it always works then. You can artificially make an image larger with blank space around it to make hitting it more accurate.

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