In my project ,there is a demand about UITextView. when I tap the link in UITextView, our app should open a webview Controller to show the linked content; when i long press the link in UITextView, our app should show some menu about copy and paste.now i can implement the second situation in UIInputViewDelegate
(BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange
although the shouldInteractWithURL is fired, i can't recognize the relative tag between the tap event and long press event.
then i breakpoint at the end of
(BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange
method,and i use lldb to find some information about tap event and long press event as follow:
long press event:
frame #1: 0x0000000112b46214 UIKit`-[_UITextViewInteractableLink allowInteraction] + 165
frame #2: 0x0000000112b452c3 UIKit`-[_UITextViewInteractableItem handleLongPress] + 22
frame #3: 0x0000000112b45055 UIKit`-[UITextView(LinkInteraction) validateInteractionWithLinkAtPoint:] + 287
frame #4: 0x00000001125edac9 UIKit`-[UITextInteractionAssistant(UITextInteractionAssistant_Internal) longDelayRecognizer:] + 281
frame #5: 0x00000001125dbb28 UIKit`_UIGestureRecognizerSendTargetActions + 153
tap event:
frame #1: 0x0000000112b46214 UIKit`-[_UITextViewInteractableLink allowInteraction] + 165
frame #2: 0x0000000112b45181 UIKit`-[_UITextViewInteractableItem handleTap] + 33
frame #3: 0x0000000112b45055 UIKit`-[UITextView(LinkInteraction) validateInteractionWithLinkAtPoint:] + 287
frame #4: 0x00000001125ed782 UIKit`-[UITextInteractionAssistant(UITextInteractionAssistant_Internal)
i find out some difference about the two event;handleTap or handleLongPress is fired in different scene. so any solution to capture the long press event or disable the system's long press event then add my own long press event to handle long event on linkedText in UITextView?