Cordova方法

一,Js与oc交互

方法1,拦截请求;方法2,拦截页面跳转


方法1,js使用 XMLHttpRequest 发起请求,拦截方法

+ (BOOL)canInitWithRequest:(NSURLRequest*)theRequest 分析


方法2,cordova用一个透明的frame作为webview加载request,拦截方法

- (BOOL)webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType

二,oc->js

发送js命令 [webView stringByEvaluatingJavaScriptFromString:@"alert('hello world!')【js语法】"];

你可能感兴趣的:(Cordova方法)