Перехватить жест панорамирования при перетаскивании маркеров выделения текста на iOS - PullRequest
0 голосов
/ 22 февраля 2020

Кто-нибудь знает, как получать события жестов при перетаскивании синих маркеров во время выделения текста на UITextField?

Я прикрепил UIPanGestureRecognizer к UITextField, но странным образом это не получается вызывается при перетаскивании синих маркеров:

image

Normal pans and moving the cursor are detected, but for some reason the blue handles swallow the drag gesture on my view. My use case depends on knowing when the user is trying to move those blue handles. Any help is much appreciated!


Other context

Relevant code of the UIPanGestureRecognizer which is attached to the UITextField:

panGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(handlePan))
panGestureRecognizer.delegate = self

self.textField.addGestureRecognizer(panGestureRecognizer)

...

@objc func handlePan(_ pan: UIPanGestureRecognizer) {
    self.label.text = "Handling pan gesture on UITextField"
    if pan.state == .ended {
        self.label.text = "<Pan Ended>"
    }
}


func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
    if gestureRecognizer == self.panGestureRecognizer {
        return true
    }
    return false
}

Я подумал об использовании метода делегата textFieldDidChangeSelection, но даже если выбор не меняется, мне нужно знать, где пользователь двигает пальцем. (например, они могут перемещать свой палец за пределы текста, поэтому выбор больше не меняется, но я все еще хочу знать, что они пытаются.)

...