UIWebView with contentEditable (html editing), first responder handling?

前端 未结 5 1119
一生所求
一生所求 2020-11-30 07:45

I\'m making an html editor component for an app (using UIWebView with contentEditable in iOS 5.0), and got stuck at how to handle UIWebView first responder status

[w

5条回答
  •  失恋的感觉
    2020-11-30 08:52

    I met the same problem recently, but solved it using pure JavaScript. Actually it doesn't need any Objective-C First Responder related methods. I just used the JavaScript to change the UIWebView's content - the targeting HTML element's contentEditable attribute value according to the requirement.

    For example, using the following code to hide the Keyboard that called by the UIWebView's editable content:

    [webView stringByEvaluatingJavaScriptFromString:@"document.getElementById('target').setAttribute('contentEditable','false')"];
    

    Hope this is helpful. :)

提交回复
热议问题