Reputation: 1117
I have a UItextView created with the codes to which I have assigned some gestures. The UItextView should not be editable and I also wanted to remove the possibility to select the text by press and holding on it, including the menu cut/paste which shows up. all over internet I found:
- (BOOL)canBecomeFirstResponder {
return NO;
}
I inserted this code in my file, and set the text.delegate = self. I even included UItextViewDelegate in the .h file What should I do?
Upvotes: 0
Views: 962
Reputation: 57040
You should modify the editable
property of the UITextView
.
To disabled copy paste, the easiest way would be to subclass the UITextView, and implement canPerformAction:withSender:
like so:
@interface MyTextView : UITextView @end
@implementation MyTextView
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
return NO;
}
@end
If you are using a XIB or Storyboard to layout your UI, make sure to give the text view the correct class.
Upvotes: 1