I'm having a hard time getting the UITextView
to disable the selecting of the text.
I've tried:
canCancelContentTouches = YES;
I've tried subclassing and overwriting:
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
(But that gets called only After the selection)
- (BOOL)touchesShouldCancelInContentView:(UIView *)view;
(I don't see that getting fired at all)
- (BOOL)touchesShouldBegin:(NSSet *)touches
withEvent:(UIEvent *)event
inContentView:(UIView *)view;
(I don't see that getting fired either)
What am I missing?
I've found that calling
works quite well.
To do this first subclass the UITextView
and in the implementation do the following
this should work fine,
Swift 4, Xcode 10
This solution will
Make sure you set the delegate to YourViewController
Then
Did you try setting userInteractionEnabled to NO for your UITextView? But you'd lose scrolling too.
If you need scrolling, which is probably why you used a UITextView and not a UILabel, then you need to do more work. You'll probably have to override
canPerformAction:withSender:
to returnNO
for actions that you don't want to allow:For more, UIResponderStandardEditActions .
For swift, there is a property called "isSelectable" and its by default assign to true
you can use it as follow: