After trying a lot of different answers from SO, I have decided to ask my own question.
I have a UITableViewCell which contains UITextView. The textview could contain both plain text or links. I basically want the links to be selectable but long pressing on anywhere other than the link should show the menu actions such as copy and paste.
What I have tried so far. I have subclassed UITextView
-(BOOL)canBecomeFirstResponder {
return NO;
}
I have set bodyTextView.selectable = NO
. This does provide the desired effect, but the links become unselectable.
Once I change to bodyTextView.selectable = YES
, the links are selectable but longpressing on a textview which has only text in it, selects the text with no actions as shown.
Ideally I would want only the links to be selectable. I have also tried
- (void)textViewDidChangeSelection:(UITextView *)textView {
if(!NSEqualRanges(textView.selectedRange, NSMakeRange(0, 0))) {
textView.selectedRange = NSMakeRange(0, 0);
}
}
This definitely removes the selection, but still cannot show the popup action menus. Any help would be appreciated.