mirror of
https://github.com/zhigang1992/HybridWebView.git
synced 2026-01-12 22:48:01 +08:00
22be186c02fbdbb3caa53e7102e2100a8b531bb0
HybridWebView
Native object inject to javascript environment. You can call native method from UIWebView, and send the result back to web page. It also support async callback handler.
###Usage:
First of all, you should import UIWebView+AddJavaScriptInterface.h
Injection:
[self.webView addJavascriptInterfaces:wSelf WithName:@"ViewController"];
Native code:
@interface ViewController : UIViewController
- (void)passArrayFromJS:(NSArray*)arr;
- (NSArray*)callArray;
@end
Javascript call:
ViewController.passArrayFromJS([1, 2, "2"]);
ViewController.callArray();
Async :
You can add a callback at last if you will get the result later.
ViewController.callArray( function(ret){console.log(ret)} );
###Safari web inspector:
###Problem
Only support pass string, array or dictionary now.
Description
Languages
Objective-C
88.3%
JavaScript
9.5%
HTML
2.2%