CHWebView is a lightweigh object-c implemented basecontroller for webview.It's convenient to use webview between WKWebView with UIWebView,both support progressview when you load web.
You can download zip and drag CHWebView File in your project,also you can install with pod.
pod 'CHWebView'
- Every controller base on CHWebViewContoller will display progreesview when you loading or use CHWebViewContoller init .
- You can load local resource file in your project more than remote url.
- It will be quick to call js function also convenience when js calling native code.
- Support WKWebView and UIWebView.
- iOS 8.0+,
- Xcode 7.3 or above
- JavaScriptCore
- WebKit
- (instancetype)initWithURL:(NSString *)url;
- (instancetype)initWithFile:(NSString *)url;
- (instancetype)initWithURL:(NSString *)url withOutNavtionBar:(BOOL)hidden;
- (instancetype)initWithFile:(NSString *)url withOutNavtionBar:(BOOL)hidden;
- (NSArray<NSString *> *)registerJavascriptName{
return @[@"native",@"show"];
}
- (void)native:(NSDictionary *)dic{
}
- (void)show:(id)body{
}
function nativeFounction() {
var message = { 'message' : 'Hello, JS!', 'numbers' : [ 1, 2, 3 ] };
window.webkit.messageHandlers.native.postMessage(message);
}
function showUIFuction(){
window.webkit.messageHandlers.show.postMessage('');
}
function nativeFounction() {
var message = { 'message' : 'Hello, JS!', 'numbers' : [ 1, 2, 3 ] };
native(message);
}
function showUIFuction(){
show('call OC function Show')
}
- (void)invokeJavaScript:(NSString *)function;
- (void)invokeJavaScript:(NSString *)function completionHandler:(void (^)( id, NSError * error))completionHandler;