Interaction between oc and js ----- WKWebView, oc ----- wkwebview
I have studied the interaction between oc and js over the past few days.
Interaction between oc and js is a cross-platform communication between iOS and javaScript. To reduce development costs, the company developed Android and iOS apps, by loading javaScript through webView, you only need to do some interactive work, so that pages written in javaScript can be used simultaneously on Android and iOS.
Methods In WKWebView
1. Call js methods in OC (I think oc transmits values to js)
Yes
<Span style = "background-color: rgb (255,255,255);">-(void) evaluateJavaScript :( NSString *) javaScriptString completionHandler :( void (^) (id, NSError *)) completionHandler; this method </span>
Parameter 1: @ param is the js method called and the value is passed.
Parameter 2: IfJavaScript
Code error.CompletionHandler
Processing.
2. WKWebView registers the WKScriptMessageHandler agent when js transmits values to oc.
-(
-(Void) userContentController :( WKUserContentController *) userContentController didReceiveScriptMessage :( WKScriptMessage *) message; <span style = "color: # ffffff;"> </span>
Parameter 2: Information transmitted by js to oc