Tap gesture recognizer interferes with URL taps in UITextView

linktextattributes swift 4
nslinkattributename swift 4
uitextview actions
uitextview attributed text
tappable attributed string swift
uilabel detect tap on word swift 4
tappable links in nsattributedstring
swiftui hyperlink

I have a disabled text view with a tap gesture recognizer attached to it. The problem is that this gesture recognizer intercepts all taps including those made on autodetected URLs (text view has data detectors turned on). Is there any way to prevent it from happening, so when a user taps an URL it's handled by text view itself (opening in Safari) and when a user taps somewhere else then my gesture recognizer is called?

The best way would be if you could access the gesture recognizer used by the data detectors (then specifying that your tap recognizer should have lower priority than that one, by using the delegate's gestureRecognizer:shouldRequireFailureOfGestureRecognizer: etc), but I don't think this is possible (anyone feel free to correct me here if I'm wrong).

Instead, you could try to add a delegate to the text view and check if the textView:shouldInteractWithURL:inRange: was called during the active period of your gesture recognizer (then only run your handler when not handled by the UITextView).

ios Tap gesture recognizer interferes with URL taps in UITextView , ios Tap gesture recognizer interferes with URL taps in UITextView? I tried shouldInteractWithURL: but it's called only after a long press on an URL when it� UITap Gesture Recognizer is a concrete subclass of UIGesture Recognizer. For gesture recognition, the specified number of fingers must tap the view a specified number of times. Although taps are discrete gestures, they are discrete for each state of the gesture recognizer.

Please make sure your textview is not a subview of other view. If it is a subview, so add UITextViewDelegate for the top view and then add this one in viewDidLoad:

 - (void)viewDidLoad
{
    [super viewDidLoad];
    yourTextview.delegate = self;
    yourTextview.editable = NO;
    yourTextview.selectable = YES;
    ...
}

Swifty Approach to Handling UITextViews With Links in Cells, Let's say that we have a UITextView that has link detection and maybe and then UITextView automatically handles link tapping, which we can� Questions: In an iOS 7 app, I have a UITextView with a link in it, but tapping the link doesn’t fire. It only responds to an awkward “tap and hold”. I want it to respond as soon as a user taps on it, like how a UIWebView link tap works.

A bit hacky but it works:

if let recognizers = yourTextView.gestureRecognizers {
    for recognizer in recognizers {
        if recognizer.name == "UITextInteractionNameLinkTap" {
            myCustomTapGestureRecognizer.require(toFail: recognizer)
        }
    }
}

The name of the recognizer for detecting links is "UITextInteractionNameLinkTap"

choefele/CCHLinkTextView: UITextView subclass with links , UITextView subclass with links that provides instant callbacks for taps and is non-editable and non-selectable as this would interfere with the link gestures. tapAreaInsets : Expands or shrinks the tap area of the link text (default: {-5, -5, -5, -5}) Note that you have to require CCHLinkTextView 's gesture recognizer to fail� The tap gesture is used for tap detection and is implemented with the TapGestureRecognizer class. To make a user interface element clickable with the tap gesture, create a TapGestureRecognizer instance, handle the Tapped event and add the new gesture recognizer to the GestureRecognizers collection on the user interface element.

ios, Tap gesture recognizer interferes with URL taps in UITextView. 发表于 2014-01- 29 16:54:20. 活跃于 2019-� Ich habe ein UITextView, das einen NSAtributedString anzeigt. Diese Zeichenfolge enthält Wörter, die ich anpassbar machen möchte. Wenn sie angetippt werden, werde ich zurückgerufen, damit ich eine Aktion ausführen kann. Mir ist klar, dass UITextView Taps auf einer URL erkennen und meinen Delegaten zurückrufen kann, aber das sind keine URLs.

Disable Magnifing glass in UITextview, but not URL Link and Phone , Disable Magnifing glass in UITextview, but not URL Link and Phone number events - ios. addGestureRecognizer(gestureRecognizer) } the textview will be in a for avplayer but that time even gestures are also not taking user actions ( taps).Even i Your gesture recognizer might interfere with your custom picker touch. Native UITextView links gesture recognizers are broken on iOS 11.0-11.1 and require a small delay long press instead of a tap: Xcode 9 UITextView links no longer clickable You can properly support links with your own gesture recognizer and you can disable text selection by subclassing UITextView and forbidding the gestures that can select something or tap something.

UITextView link selectable without rest of text being selectable, override func gestureRecognizerShouldBegin(_ gestureRecognizer: Text view becomes selectable after tapping message � Issue #1159 , Proving a By default , it is non-editable and non-selectable as this would interfere with the link gestures. TextView, android:autoLink, Controls whether links such as urls and email� If you are using a UIScrollView (or UITableView), then you will need to add a tap gesture recognizer to it. I use storyboard most of the time. To add, drag a Tap Gesture Recognizer (in control library) to the UIScrollView. In the tap gesture recognizer, control-drag the “Sent Actions” to your .m implementation file, and add a method eg.

Comments
  • I tried shouldInteractWithURL: but it's called only after a long press on an URL when it becomes highlighted. If a user just do a quick tap on an URL then this method is not called. Maybe it's a "feature" ie if you want to open an URL tap longer, otherwise you'll start editing. I actually started to prefer this behavior. Could be useful when you want to edit a long URL instead of opening it. Thanks anyway :)