Search code examples
swiftsprite-kituitapgesturerecognizergestures

Swift UITapGestureRecognizer Slow


I am having delays with using the UITapGestureRecognizer, I know this will be due to:-

singleTap.requireGestureRecognizerToFail(doubleTap)

but this is required due to single tap being called at the same time as a double tap. Is there another way around this issue?

let singleTap:UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: Selector("singleTap:"))
singleTap.numberOfTapsRequired = 1
singleTap.requireGestureRecognizerToFail(doubleTap)
view.addGestureRecognizer(singleTap)

Solution

  • If you require that the double tap fails before the single tap can be detected then there is absolutely no way that you can get around this.

    Could you get around this by requiring that your single taps fails before your double tap recognises?

    doubleTap.requireGestureRecognizerToFail(singleTap)
    

    That should mean that the double tap would only fire if the single tap wasn't detected, essentially prioritising the single tap