I have searched a lot for how to detect link in UITextView
with editable property set to true
, but didn't find any solution. All solutions suggest to set editable to NO
, but by requirement I can't set editable to NO
.
Unfortunately you cannot have an editable UITextView with clickable links.
But you can try this code it might 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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With