如何使拼写检查在UIWebView上运行?

时间:2017-09-21 15:18:56

标签: ios uiwebview spell-checking

我正在尝试让UIWebView拼写检查一些可编辑的div(显示红色下划线)。

let html = "<div id="content" spellcheck="true" contenteditable="true" style = 'width:200px;height:200px' Misspel</div>"    
self.messageWebView.loadHTMLString(html!, baseURL: nil)

似乎不起作用。但是我发现了一个奇怪的行为。如果我手动点击可编辑区域然后单击其他按钮以使div失去焦点,则会开始强调拼写错误的单词:

enter image description here

我试过

var mydiv = document.getElementById('content');
mydiv.focus();
setTimeout(function {....mydiv.blur();}, 1000);

这不会触发拼写检查。只有手动点击某个元素才能使div失去焦点才能使其正常工作。我也试过WKWebVIew。不行。我在iPhone 6s上测试了它,10.3.2 任何想法都表示赞赏。

0 个答案:

没有答案
相关问题