资 源 简 介
This project consists in a lightweight api for iPhone to call Objective-C code from Javascript in a UIWebView. A Javascript code is provided, which is able to communicate to an extension of Cocoa"s UIWebview. The JSBridge does not use any private api, and has a dependency on json framework for Objective-C.
Download and add to your XCode project the files JSBridgeWebView.h, JSBridgeWebView.m and JSBridge.js. You will also need to add the JSON framework.
Step-By-Step
After embedding the code in your project, you need to hook up things. Here, I will try to give a quick step-by-step.
Instanciate a new JSBridgeWebView and place it in whatever view you want.
Implement the JSBridgeWebViewDelegate, and the method - (void)webView:(UIWebView*) webview didReceiveJSNotificationWithDictionary:(NSDictionary*) dictionary