简体   繁体   中英

Miss a single tap randomly

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%?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM