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?
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.
UIPinchGestureRecognizer
scale
velocity
NB: "negative" can be misleading. "Less" - 0.0 < scale < 1.0, "more" - scale > 1.0.
0.0 < scale < 1.0
scale > 1.0
"scale" 1 1 -. .
, , , 5 ( ), 1.0 - . - Apple, .
, , NSLog
NSLog(@"Scale: %.2f | Velocity: %.2f",pinch.scale,pinch.velocity);
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; }