ios - UILongPressGestureRecognizer action depending on press duration -


I need to take different actions based on the press duration of the UILongPressGestureRecognizer

Now I am thinking of two different ways of achieving it.

A) Add identifiers to two different gestures, with minimum pressure reduction of G1 with G1 and G2 with minimum perduction, and by any means UIGestureRecognizerDelegate Cancel G1 if G2 is successful.

b) Add a single signal identifier and apply custom management and state management to choose the right work.

Which is the preferred method and why?

UILongPressGestureRecognizer You can measure time between code> UIGestureRecognizerStateEnded

EDIT: To handle this condition, you can use a NSTimer You can.

  if (gest Ure.state == UIGestureRecognizerStateBegan) {self.timer = [NSTimer scheduled timer with time interval: 1.0f target: self selector: @selector (forOneSec :) userInfo: zero repeats : No]; [Self. Tiger fire]; }   

If not touched, your long press method will be called after 1 second. If the user stops touching events before 1 second, then you need to invalidate the timer and call another method.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -