Search code examples
iphoneuitextviewsubclassuigesturerecognizeruimenucontroller

Hide UIMenuController in UITextView


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.


Solution

  • 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.