UITextView Detects Link with Editable True Property

I searched a lot how to find the link in a UITextView with the editable property set to true , but did not find any solution. All solutions suggest setting NO for editing, but on demand I can’t set the editable NO value.

+5
source share
3 answers

Unfortunately, you cannot have an editable UITextView with interactive links.

But you can try this code, it can work. I get this from one tutorial: http://www.ama-dev.com/editable-uitextview-with-link-detection/

 UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(editTextRecognizerTabbed:)]; recognizer.delegate = self; recognizer.numberOfTapsRequired = 1; [self.textViewNotes addGestureRecognizer:recognizer]; - (void) editTextRecognizerTabbed:(UITapGestureRecognizer *) aRecognizer; { self.textViewNotes.dataDetectorTypes = UIDataDetectorTypeNone; self.textViewNotes.editable = YES; [self.textViewNotes becomeFirstResponder]; } - (void)textViewDidEndEditing:(UITextView *)textView; { self.textViewNotes.editable = NO; self.textViewNotes.dataDetectorTypes = UIDataDetectorTypeAll; } 
+5
source

I found this blog . From an example: to make a UITextView editable by clicking links, you must set gestureRecognizer and make the UITextView editable by clicking. Code:

 - (void)configureTextView { UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(textViewTapped:)]; recognizer.numberOfTapsRequired = 1; textView.editable = NO; textView.dataDetectorTypes = UIDataDetectorTypeLink; [textView addGestureRecognizer:recognizer]; } // Notification from the recogniser that the UITextView was tapped - (void)textViewTapped:(UIGestureRecognizer *)recognizer { UITextView *textView = (UITextView *)recognizer.view; textView.editable = YES; [textView becomeFirstResponder]; } // UITextViewDelegate method - (void)textViewDidEndEditing:(UITextView *)textView { textView.editable = NO; } 
+3
source

You can use UITapGestureRecognizer for this UITextField.

0
source

All Articles