Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find out when a pinch gesture is finished (UIGestureRecognizer)

I want to get a callback when my UIPinchGestureRecognizer finished a pinch-gesture. Moreover it would be great to know if the finished gesture was a zoom in or a zoom out.

Does anyone know a method to use? Or the approach to do?

Thanks!

like image 737
Lars Petersen Avatar asked Jul 18 '10 09:07

Lars Petersen


People also ask

What is pinch gesture on Iphone?

Overview. A pinch gesture is a continuous gesture that tracks the distance between the first two fingers that touch the screen. Use the UIPinchGestureRecognizer class to detect pinch gestures. You can attach a gesture recognizer in one of these ways: Programmatically.

What happens when you pinch to zoom?

Once zoomed in, you can move around and look at parts of the video closer. This feature looks to be made specifically for portrait mode viewing. If you're a Premium member, you can find the new feature in the YouTube app on Android; just tap your profile photo and then hit Your Premium benefits.

What is pinch gesture Android?

Detecting a pinch gesture is similar to a scroll gesture, we simply want to make sure that there are 2 fingers, they have moved beyond a certain threshold and that they are moving in opposite directions. That last bit there in italics is the difference between a scroll and a pinch.

What is pinch event?

Think about what a pinch event is: two fingers on an element, moving toward or away from each other. Gesture events are, to my knowledge, a fairly new standard, so probably the safest way to go about this is to use touch events like so: ( ontouchstart event) if (e. touches.


1 Answers

Another approach instead of overriding touchesEnded:, is that you could just check the state of the gesture recognizer in your target handler method.

  -(void)handlePinchGesture:(UIGestureRecognizer*)gestureRecognizer {    
    if(UIGestureRecognizerStateEnded == [gestureRecognizer state]){
      // do something
    }
  }
like image 137
cahlbin Avatar answered Sep 28 '22 07:09

cahlbin