Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: Is there a way to have a two tap gesture recognizers with different number of taps

vApp:

In my app, i need to run different functions on a Tap Gesture depending on how many times a user taps the image.

I have a Tap Gesture Recognizer that requires for 1 tap.

My second tap Gesture recognizer requires for 2 taps. However, if I tap it 2 times, both functions for each tap gesture are called.

Is there a way I can do this, so the two functions can be called separately and not interfere with each-other?

The problem: If i tap the image two times, it calls the goWatchVideo function and the onDoubleTap function all together. I want to avoid this.


// Gesture that requires 1 tap
let tapToWatch = UITapGestureRecognizer(target: self, action: #selector(goWatchVideo))
tapToWatch.numberOfTapsRequired = 1
postVideoView.addGestureRecognizer(tapToWatch)


// Gesture that requires 2 taps
let doubleLike = UITapGestureRecognizer(target: self, action:#selector(self.onDoubleTap))
doubleLike.numberOfTapsRequired = 2
postVideoView.addGestureRecognizer(doubleLike)

// Tried to set them up for failures
tapToWatch.require(toFail: doubleLike)
doubleLike.require(toFail: tapToWatch)



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: Is there a way to have a two tap gesture recognizers with different number of taps

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×