How disable Copy, Cut, Select, Select All in UITextView
The easiest way to disable pasteboard operations is to create a subclass of UITextView
that overrides the canPerformAction:withSender:
method to return NO
for actions that you don't want to allow:
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender{ if (action == @selector(paste:)) return NO; return [super canPerformAction:action withSender:sender];}
Also see UIResponder
Subclass UITextView and overwrite canBecomeFirstResponder:
- (BOOL)canBecomeFirstResponder { return NO;}
Note, that this only applies for non-editable UITextViews! Haven't tested it on editable ones...
This was the best working solution for me:
UIView *overlay = [[UIView alloc] init]; [overlay setFrame:CGRectMake(0, 0, myTextView.contentSize.width, myTextView.contentSize.height)]; [myTextView addSubview:overlay]; [overlay release];