JavaScript与OC的交互

JavaScript与OC有两个交互的桥梁


webView执行完js代码后可以返回一个字符串

NSString *result = [webView stringByEvaluatingJavaScriptFromString:js];

通过以下代理方法监听webView的页面跳转,并解析request,实现通过js调用OC。

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

请参考:https://github.com/kouliang/A-template-for-the-interaction-of-OC-and-JS

posted @ 2015-02-15 08:43  coderkl  阅读(117)  评论(0编辑  收藏  举报