Search code examples
objective-cioscocoa-touchuipinchgesturerecognizer

How to detect pinch in gesture vs pinch out gesture?


Instead of scaling, which I think pinch gesture is usually used for, I am looking to just detect whether the pinch was a pinch in vs pinch out so I can collapse or expand some table sections. How would I go about doing that?


Solution

  • Well, that seems an easy one. The UIPinchGestureRecognizer class has only two properties, scale and velocity. It seems logical that a negative scale would mean an inward pinch, a positive scale an outward pinch.

    NB: "negative" might be misleading. "Smaller" is 0.0 < scale < 1.0, "bigger" is scale > 1.0.