How to recognize a pinch in a gesture, not a gesture!

Instead of the scaling, which, it seems to me, is usually used for squeezing gestures, I just want to determine if the pinch was pinched, and I can collapse or expand some sections of the table. How should I do it?

+5
source share
3 answers

Well, that seems easy. A class UIPinchGestureRecognizerhas only two properties: scaleand velocity. It seems logical that a negative scalewould mean an internal pinch, a positive scaleexternal pinch.

NB: "negative" can be misleading. "Less" - 0.0 < scale < 1.0, "more" - scale > 1.0.

+7
source

"scale" 1 1 -. .

, , , 5 ( ), 1.0 - . - Apple, .

, , NSLog

NSLog(@"Scale: %.2f | Velocity: %.2f",pinch.scale,pinch.velocity);
+10

You were right to look at the scale property, but it switches to 1 rather than zero.

    - (BOOL) pinchWasOutwards: (UIGestureRecognizer *) gestureRecognizer
    {
        return gestureRecognizer.scale> 1;
    }
+2
source

All Articles