Can you add to GestureRecognizer of the same type to one view?
-
11-06-2021 - |
문제
I need to detect long-press on a UITextView, which already recognises long-press thus it has a long press recognizer, can I create a new one and add to it? How will it work then, two recognizers will get the same callback when you long-press?
Thanks!
해결책
Just add two UILongPressRecognizer
s with different selectors (initWithTarget:selector:
) to the view. It should work just like you think it will work. You may need to return YES
from your delegate's -gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:
when both of your UILongPressRecognizers
are invoked simultaneously.
Note that you will likely encounter problems with Apple's recognizer for popping up the magnifier loupe.
제휴하지 않습니다 StackOverflow