Yogi
Yogi

Reputation: 3588

How to set the maximum duration between two taps in UITapGesture?

In my iOS app, I am using UITapGesture with numberOfTapsRequired equal to two. But I need to specify the maximum duration required between two taps.

If the duration taken between two taps is greater that the specified (Say 0.5 sec) the gesture should not work.

Please guide me how can I achieve this.

Thanks in advance!

Upvotes: 1

Views: 588

Answers (2)

raz0r
raz0r

Reputation: 3372

This question reminds me of how the Double Tap gesture was implemented before Apple went out and implemented it themselves in UITapGestureRecognizer.

Before all of that, we used the methods, touchesBegan and touchesEnd to keep track of the number of fingers touching the screen and also, add a delay to make sure we track double taps. Thats when we could use the time which you asked. Now, there is simply no need as R.A pointed out.

Upvotes: 1

Dinesh Raja
Dinesh Raja

Reputation: 8501

It seems like you dont need to handle the tap gesture by the way of maximum duration for each tap in your gesture. You just need to specify how many touches and taps required and in the method you can check the state of the tap gesture.

- (void)handleTap:(UITapGestureRecognizer *)sender {     
    if (sender.state == UIGestureRecognizerStateEnded)     {         
       // handling code     
     } 
  }

Above piece of code is from the apple documentation.

Upvotes: 2

Related Questions