How to make the spellcheck work on UIWebView?

Viewed 275

I'm trying to make UIWebView to spell check some editable div (show the red underline).

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

Doesn't seem to work. However I noticed one strange behavior. If I manually click the editable area and then click some other button to make the div lose focus it starts underlining the misspelled words:

enter image description here

I tried

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

This doesn't trigger the spellcheck. Only manual clicking on some element to make the div lose focus makes it working. I also tried WKWebVIew. Doesn't work. I tested it on iPhone 6s, 10.3.2 Any ideas are appreciated.

0 Answers
Related