Disable multiple long-press gestures simultaneously

ios, objective-c, uigesturerecognizer

Solution

You have actually several ways to solve your problem:

Set `exclusiveTouch` to YES for all your image views. It will block the delivery of touch events to other views in the same window.

Or you can set flag to ignore other recognizers when one of your recognizers move to Begin state.

Or you can disable gesture recognizers (UIGestureRecognizer has `enabled` property) except current one in your delegate method and enable all of them again when gesture finishes.

Problem

I have a `UIView` and i have multiple `UIImageView's` as its subview. I have added `UILongPressGestureRecognizer` to each of these subviews. I handle this gesture in a method where i perform some animation on the sender `UIImageView`. If I long press two `ImageView's` at a time, the animation gets disrupted. Is there any way I can disable multiple long press gestures simultaneously? i.e allow only one `UIImageView` to detect LongPress gesture.

Original source