Since there's no better solution, i still used 'iterate over gesture recognizers' approach.
Code is the following:
gestureRecognizers?.forEach { (recognizer) in
if let longPressRecognizer = recognizer as? UILongPressGestureRecognizer {
longPressRecognizer.minimumPressDuration = Constants.DragLongPressMinimumDuration
}
}
Constants.DragLongPressMinimumDuration
is Double
defined in Constants
struct.
Important note: do this on collection view itself (and not cells) after setting up drag and drop.
Solution works ok for iOS versions 11 and 12.
Of course this is on the edge of using private API, actual class of that recognizer is _UIDragLiftGestureRecognizer
(which is part of private API, and UILongPressGestureRecognizer
subclass). But since we're casting it to UILongPressGestureRecognizer
, technically we're not using private API.