Search code examples
swiftconflictuipangesturerecognizer

UIPanGestureRecognizer - Avoid moving two images simultaneously - Swift


I have a ViewController with 3 UIImageView with its images. I am using Pinch, Pan and Rotate gesture on all three images. While doing Pinch or Rotation i got two finger point with opt+mouse_click. There in the finger point, if two images are pointed with each finger point, both images are moving around.

I actually don't want that move(pan) while doing opt+mouse_click, just need to rotate or zoom the images with two finger points.

Help me to resolve, Thanks in advance


Solution

  • You can try to limit the UIPanGestureRecognizer 's finger that touch on screen to 1 to avoid it. Rotate or zoom will need 2 fingers.

    More information from Apple's doc

    The maximum number of fingers that can be touching the view for this gesture to be recognized.

    https://developer.apple.com/documentation/uikit/uipangesturerecognizer/1621208-maximumnumberoftouches