HTWebView 是一套对 WebView 进行功能扩展的解决方案。
- 集成WebViewJavascriptBridge提供的JavaScript与Navitve的通信机制
- 与页面导航管理HTUniversalRouter结合使用,支持到Native页面的跳转
- 支持页面加载进度条的显示
- 网页滑动后退
- 支持页面滑动(右滑)后退
- 提供具备基本功能的WebView Controller
####创建UIWebView
/*创建UIWebView*/
UIWebView* myWebView = [[UIWebView alloc]init];
/*ViewContrller遵循UIWebViewDelegate*/
MyViewContrller: UIViewController <UIWebViewDelegate>
####创建进度条,MyProcessView需要遵循HTWebViewProgressViewProtocol
/*自定义进度条,需要遵循HTWebViewProgressViewProtocol*/
MyProcessView : UIView <HTWebViewProgressViewProtocol>
MyProcessView* processView = [[MyProcessView alloc]init];
####创建HTWebViewDelegate
/*根据需要配置HTWebViewDelegate*/
HTWebViewDelegate* webViewDelegate =
[HTWebViewDelegate delegateForWebView:_webView
webviewDelegate:self
enableJavascriptBridge:YES
withJavascriptDefaultHandler:^(id data, WVJBResponseCallback responseCallback) {
HTDemoLogDebug(@"ObjC received message from JS: %@", data);
responseCallback(@"Response for message from ObjC");
}
enableProgress:YES
withProgressView:_gradView
enableGestureNavigation:YES];
####获取WebViewJavascriptBridge,做JavaScript与Objective-C的通信
WebViewJavascriptBridge* bridge = [webViewDelegate javascriptBridge];
[bridge send:@"A string sent from ObjC before Webview has loaded." responseCallback:^(id responseData) {
NSLog(@"objc got response! %@", responseData);
}];
pod 'HTWebView' , :git=>'https://g.hz.netease.com/HTIOSUI/HTWebView.git'
pod install
或pod update
- #import "HTWebView.h"
该项目最低支持iOS 7.0
和Xcode 7.0
HTWebView,详情见LICENSE文件。