0

I am making a rich text editor app. When app started, UIWebView loads a html file which contains a content editable div. When I touch a word, UIWebView shows a menu suggest some words instead of selected word. How can I turn off this menu?

That's what I say: https://i.stack.imgur.com/Xu4A9.png

This is my code:

- (void)viewDidLoad
{
    webText=nil;
    NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
    [self.editor loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]]];
    self.editor.delegate=self;    

    [super viewDidLoad];
}

-(BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
    if (action == @selector(defineSelection:))
    {
        return NO;
    }
    else if (action == @selector(translateSelection:))
    {
        return NO;
    }
    else if (action == @selector(copy:))
    {
        return NO;
    }

    return [super canPerformAction:action withSender:sender];
}
amone
  • 3,712
  • 10
  • 36
  • 53

1 Answers1

0

Here you have to return NO for all the specific methods the menu controller performs.

-(BOOL)canPerformAction:(SEL)action withSender:(id)sender 
{
    if (action == @selector(defineSelection:))
    {
        return NO;
    }
    else if (action == @selector(translateSelection:))
    {
        return NO; 
    }
    else if (action == @selector(copy:))
    {
        return NO;
    }

    return [super canPerformAction:action withSender:sender];
}

Hope this helps .

IronManGill
  • 7,222
  • 2
  • 31
  • 52