第一步:引入库文件
import <JavaScriptCore/JavaScriptCore.h>
第二步:实现UIWebView 代理
//网页加载完成
- (void)webViewDidFinishLoad:(UIWebView *)webView{
//隐藏网络请求加载图标
[UIApplication sharedApplication].networkActivityIndicatorVisible = false;
//取得html内容
NSLog(@"%@",[self.webView stringByEvaluatingJavaScriptFromString:@"document.title"]);
if (_webView.scrollView.mj_header.state == MJRefreshStateRefreshing)
{
[_webView.scrollView.mj_header endRefreshing];
}
JSContext *context = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
context[@"oneKeyShare"] = ^() {
NSArray *args = [JSContext currentArguments];
[self oneKeyShare];
};
}