【问题标题】:UIWebView shows word suggest menu when user touches a wordUIWebView 在用户触摸单词时显示单词建议菜单
【发布时间】:2013-08-07 12:20:03
【问题描述】:

我正在制作一个富文本编辑器应用程序。当应用程序启动时,UIWebView 会加载一个包含内容可编辑 div 的 html 文件。 当我触摸一个单词时,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];
}

【问题讨论】:

  • @Arbitur 我已经对其进行了测试但无法正常工作。我使用了一个可内容编辑的 div。不是输入或文本区域。
  • 尝试第二个答案。将 div 更改为 textarea
  • @Arbitur 如果我将 div 更改为 textarea 如何使用“document.execCommand”进行富文本编辑?
  • 对不起,但我不知道。

标签: iphone ios uiwebview autosuggest


【解决方案1】:

这里你必须为菜单控制器执行的所有特定方法返回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];
}

希望这会有所帮助。

【讨论】:

  • 你设置了代表吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-02-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-22
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多