iosobjective-ciphoneuitextview

UITextView disabling text selection


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?


Solution

  • Issue How disable Copy, Cut, Select, Select All in UITextView has a workable solution to this that I've just implemented and verified:

    Subclass UITextView and overwrite canBecomeFirstResponder:

    - (BOOL)canBecomeFirstResponder {
        return NO;
    }
    

    Note that this disables links and other tappable text content.