2013-08-06 92 views
0

我正在制作一个富文本编辑器应用程序。当应用程序启动时,UIWebView加载一个包含内容可编辑div的html文件。 当我碰到一个单词时,UIWebView会显示一个菜单,显示一些单词而不是选定的单词。我怎样才能关闭这个菜单?当用户触摸某个单词时,UIWebView显示单词建议菜单

这就是我说: http://i.stack.imgur.com/Xu4A9.png

这是我的代码:

- (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]; 
} 
+0

显示我的回答 –

+0

http://stackoverflow.com/questions/3416867/how-can-i-disable-the-spell-checker-on-text-inputs-on-the-iphone test this – Arbitur

+0

@Arbitur我已经测试过它,并没有工作..我使用contenteditable div。不是输入或textarea。 – amone

回答

0

在这里,你必须回到NO所有的具体方法菜单控制器执行。

-(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]; 
} 

希望这会有所帮助。

+0

不,它不起作用。 – amone

+0

您是否设置了代表? – IronManGill

+0

我更新了我的答案..你可以看看.. – amone

相关问题