问题
Subclassed UITextView
Here is h file
@interface CTextView : UITextView {
}
@end
Here is m file code
#import "CTextView.h"
@implementation CTextView
- (BOOL)canBecameFirstResponder {
return NO;
}
@end
Here is first UIViewController file in which subclassed UITextview is using
#import "First.h"
#import "CTextView.h"
textView = [[[CTextView alloc] initWithFrame:CGRectMake(0, 0, 320, 410)]autorelease];
[self.view addSubview:textView];
But still not able to prevent copy select all from UITextView. Please let me know if i am still missing anything or doing wrong.
Thanks for help.
回答1:
Use this to disable copy:
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
return NO;
}
回答2:
Got it. Now it is working
Here is the code for reference for anyone need it
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
[UIMenuController sharedMenuController].menuVisible = NO; //do not display the menu
if (action == @selector(copy:))
{
return NO;
}
else if (action == @selector(selectAll:))
{
return NO;
}
[self resignFirstResponder]; //do not allow the user to selected anything
return NO;
return [super canPerformAction:action withSender:sender];
}
Now only problem having is Zooming. Now i have to work on that to disable it from UITextView.
回答3:
Have you set the user interaction enabled to YES?
来源:https://stackoverflow.com/questions/10636880/hide-uimenucontroller-in-uitextview