• Stars
    star
    136
  • Rank 267,670 (Top 6 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created over 8 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

统一简化UIWebView和WKWebView的API使用,在此基础上实现进度条和简单JS交互事件

CHWebView 中文使用说明文档

CHWebView is a lightweigh object-c implemented for webview.It's WKWebView and UIWebView adapter. Support progress view when web is loading and html can convenient to call object-c method.

CocoaPods Platform info License MIT

image

Features

  • You can use UIWebView or WKWebView as usual.
  • You can load local resource file in your project more than remote url.
  • JavaScript call native method just coding in a line .
  • Support CHWebViewController to load web.

Install

You can download zip and drag CHWebView File in your project,also you can install with pod.

pod 'CHWebView'

Requirements

  • iOS 8.0+,
  • Xcode 7.3 or above
  • JavaScriptCore
  • WebKit

Init CHWbeView

    CHWebView *webView = [[CHWebView alloc]initWithFrame:rect];
    [webView loadRequest:self.request];
    webView.delegate = self;
    [self.view addSubview:webView];

If you want change UIWebView

  - ( instancetype)initWithUIWebView; 
  - ( instancetype)initWithUIWebView:(CGRect)frame;

Also you can use CHWebViewConroller

- (instancetype)initWithURL:(NSString *)url;

- (instancetype)initWithFile:(NSString *)url;

JS Call Object-C OC CODE

- (NSArray<NSString *> *)registerJavascriptName{
    return @[@"fetchMessage",@"show"];
}
- (NSObject *)registerJavaScriptHandler{
    return self;
}
- (void)fetchMessage:(NSDictionary *)dic{
}
- (void)show:(NSDictionary *)dic{

}

JavaScript Code

Html can found window.NativeBridge object . window.NativeBridge({f},{j}) @parameter f is native method name maybe it's named show or something else,you can defind it. @parameter j is parameter used by method.

 function nativeFounction() {
       var obj = { 'message' : 'Hello, JS!', 'numbers' : [ 1, 2, 3 ] };
       window.NativeBridge('fetchMessage',obj)
   }
    function showUIFuction(){
       window.NativeBridge('show')
    }

Object-C Call JavaScript

- (void)invokeJavaScript:(NSString *)function;

- (void)invokeJavaScript:(NSString *)function completionHandler:(void (^)( id, NSError * error))completionHandler;

CHWebView Design

More Repositories

1

XEBEventBus

EventBus Object-C Version(EventBus 的Object-C语言版本)
Objective-C
13
star
2

CHChatKit

CHChatKit is an Chat Components and Instant Messaging library written in Object-C.
Objective-C
10
star
3

CHNetworking

network framework
Objective-C
7
star
4

Swift-Design-Patterns-for-iOS

Describe the book 23 kinds of design patterns base on Swift,The reference to Objective-C Design Patterns.描述和介绍用Swift实现23种设计模式的书籍,帮助大家提高自己的设计能力,一起巩固和提升Swift语言的知识,欢迎大家给出建议和发布自己的见解。
5
star
5

CHProgressHUD

一个自定义HUD样式的常用控件
Objective-C
4
star
6

CHMediatorDemo

组件化开发的解决方案
Objective-C
4
star
7

CHImagePicker

通过单例方法访问手机相册,获取用户选中的图片实现头像上传
Objective-C
3
star
8

CHRequest

基于Alamofire在Swift语言上实现的网络请求库协议方式拼装一个Request请求,实现大部分通用逻辑和数据解析工作。
Swift
3
star
9

CHSocialService

解耦第三方的快速分享和第三方授权登录的类库,目前版本基于UMengSocial5.0
Objective-C
3
star
10

CHEditorDemo

基于Objective-C语言实现图文混排的编辑器
Objective-C
2
star
11

Simpler

(已废弃)基于Alamofire在Swift语言上实现的网络请求库
Swift
1
star
12

Blog

博客文章
CSS
1
star
13

CHFramework

集合所有iOS组件化控件的Demo,包括CHUIKit,CHTabFramework,CHLoginModal,ASNavigator,CHSocialService
Objective-C
1
star
14

CHViewModel

在MVVM模式中,基于ReactiveCocoa框架,创建一个基础的ViewModel用来输出各种信号。
Objective-C
1
star
15

chausson.github.io

技术博客git
HTML
1
star
16

CHDragView

基于Swift实现的动画拖拽控件
Swift
1
star