Commit fb4806d97c11451e8b69c5e2c43b75d7d693c8a4

Authored by zhangxiaowen
1 parent 866f3c84

no message

CNLiveBalanceModule/Classes/Detail/CNLiveBalanceDetailController.m
... ... @@ -99,7 +99,6 @@ static const CGFloat height = 44;
99 99 }
100 100 return _navigationBar;
101 101 }
102   -
103 102 - (UIView *)tline {
104 103 if (!_tline) {
105 104 _tline = [[UIView alloc] initWithFrame:CGRectMake(0, NavigationContentTop, self.view.bounds.size.width, 0.5)];
... ... @@ -126,7 +125,6 @@ static const CGFloat height = 44;
126 125 }
127 126 return _titleCategoryView;
128 127 }
129   -
130 128 - (UIView *)bline {
131 129 if (!_bline) {
132 130 _bline = [[UIView alloc] initWithFrame:CGRectMake(0, _titleCategoryView.bottom, self.view.bounds.size.width, 0.5)];
... ... @@ -134,7 +132,6 @@ static const CGFloat height = 44;
134 132 }
135 133 return _bline;
136 134 }
137   -
138 135 - (JXCategoryListContainerView *)listContainerView {
139 136 if (_listContainerView == nil) {
140 137 _listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
... ... @@ -142,7 +139,6 @@ static const CGFloat height = 44;
142 139 }
143 140 return _listContainerView;
144 141 }
145   -
146 142 - (NSArray *)titles{
147 143 if (!_titles) {
148 144 _titles = [NSArray arrayWithObjects:@"全部", @"收入", @"支出", nil];
... ...
CNLiveBalanceModule/Classes/TradingRecord/CNLiveTradingRecordDetailHeaderView.m
... ... @@ -76,7 +76,7 @@ static const NSInteger height = 40;
76 76 self.shopIcon.image = [self getImageWithImageName:@"trading_record_union_pay" bundleName:@"CNLiveBalanceModule" targetClass:[self class]];
77 77 self.shopName.text = @"银行卡";
78 78 } else {
79   - self.shopIcon.image = [UIImage imageNamed:@""];
  79 + self.shopIcon.image = nil;
80 80 self.shopName.text = @"未知";
81 81 }
82 82 } else if ([model.sourceType containsString:@"order"] || [model.sourceType containsString:@"payment"]) {
... ...
Example/CNLiveBalanceModule.xcodeproj/project.pbxproj
... ... @@ -9,11 +9,7 @@
9 9 /* Begin PBXBuildFile section */
10 10 008EDC6D9F59708FC31D66E2 /* Pods_CNLiveBalanceModule_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DF1592377FBDD3732275DFDB /* Pods_CNLiveBalanceModule_Example.framework */; };
11 11 08827AFE23A8B4AC00EBF18F /* UIViewController+NavigationBarHidden.m in Sources */ = {isa = PBXBuildFile; fileRef = 08827AFD23A8B4AC00EBF18F /* UIViewController+NavigationBarHidden.m */; };
12   - 08ADA66223A381E100072772 /* CNLiveBaseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 08ADA66123A381E100072772 /* CNLiveBaseViewController.m */; };
13   - 08CA954D23A4609F001B1A99 /* CNLiveWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = 08CA954B23A4609F001B1A99 /* CNLiveWebView.m */; };
14 12 08CA955023A47090001B1A99 /* CNLiveBaseNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 08CA954F23A47090001B1A99 /* CNLiveBaseNavigationController.m */; };
15   - 08CA955923A4B492001B1A99 /* CNLiveBaseWebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 08CA955723A4B492001B1A99 /* CNLiveBaseWebViewController.m */; };
16   - 08CA955C23A4B552001B1A99 /* CNLiveInteractionWebController.m in Sources */ = {isa = PBXBuildFile; fileRef = 08CA955A23A4B552001B1A99 /* CNLiveInteractionWebController.m */; };
17 13 6003F58E195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; };
18 14 6003F590195388D20070C39A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58F195388D20070C39A /* CoreGraphics.framework */; };
19 15 6003F592195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; };
... ... @@ -45,16 +41,8 @@
45 41 /* Begin PBXFileReference section */
46 42 08827AFC23A8B4AC00EBF18F /* UIViewController+NavigationBarHidden.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+NavigationBarHidden.h"; sourceTree = "<group>"; };
47 43 08827AFD23A8B4AC00EBF18F /* UIViewController+NavigationBarHidden.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+NavigationBarHidden.m"; sourceTree = "<group>"; };
48   - 08ADA66023A381E100072772 /* CNLiveBaseViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CNLiveBaseViewController.h; sourceTree = "<group>"; };
49   - 08ADA66123A381E100072772 /* CNLiveBaseViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CNLiveBaseViewController.m; sourceTree = "<group>"; };
50   - 08CA954B23A4609F001B1A99 /* CNLiveWebView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNLiveWebView.m; sourceTree = "<group>"; };
51   - 08CA954C23A4609F001B1A99 /* CNLiveWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNLiveWebView.h; sourceTree = "<group>"; };
52 44 08CA954E23A47090001B1A99 /* CNLiveBaseNavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CNLiveBaseNavigationController.h; sourceTree = "<group>"; };
53 45 08CA954F23A47090001B1A99 /* CNLiveBaseNavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CNLiveBaseNavigationController.m; sourceTree = "<group>"; };
54   - 08CA955723A4B492001B1A99 /* CNLiveBaseWebViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNLiveBaseWebViewController.m; sourceTree = "<group>"; };
55   - 08CA955823A4B492001B1A99 /* CNLiveBaseWebViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNLiveBaseWebViewController.h; sourceTree = "<group>"; };
56   - 08CA955A23A4B552001B1A99 /* CNLiveInteractionWebController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNLiveInteractionWebController.m; sourceTree = "<group>"; };
57   - 08CA955B23A4B552001B1A99 /* CNLiveInteractionWebController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNLiveInteractionWebController.h; sourceTree = "<group>"; };
58 46 0D75FC30984EA4E2CA7EBB7D /* Pods-CNLiveBalanceModule_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CNLiveBalanceModule_Example.debug.xcconfig"; path = "Target Support Files/Pods-CNLiveBalanceModule_Example/Pods-CNLiveBalanceModule_Example.debug.xcconfig"; sourceTree = "<group>"; };
59 47 17A0C3C4449A3213C9347BB9 /* Pods-CNLiveBalanceModule_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CNLiveBalanceModule_Tests.release.xcconfig"; path = "Target Support Files/Pods-CNLiveBalanceModule_Tests/Pods-CNLiveBalanceModule_Tests.release.xcconfig"; sourceTree = "<group>"; };
60 48 2D5F9D4C44F18F703DCFAC06 /* Pods-CNLiveBalanceModule_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CNLiveBalanceModule_Example.release.xcconfig"; path = "Target Support Files/Pods-CNLiveBalanceModule_Example/Pods-CNLiveBalanceModule_Example.release.xcconfig"; sourceTree = "<group>"; };
... ... @@ -166,18 +154,10 @@
166 154 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */,
167 155 6003F5A5195388D20070C39A /* CNLIVEViewController.h */,
168 156 6003F5A6195388D20070C39A /* CNLIVEViewController.m */,
169   - 08ADA66023A381E100072772 /* CNLiveBaseViewController.h */,
170   - 08ADA66123A381E100072772 /* CNLiveBaseViewController.m */,
171 157 08827AFC23A8B4AC00EBF18F /* UIViewController+NavigationBarHidden.h */,
172 158 08827AFD23A8B4AC00EBF18F /* UIViewController+NavigationBarHidden.m */,
173 159 08CA954E23A47090001B1A99 /* CNLiveBaseNavigationController.h */,
174 160 08CA954F23A47090001B1A99 /* CNLiveBaseNavigationController.m */,
175   - 08CA954C23A4609F001B1A99 /* CNLiveWebView.h */,
176   - 08CA954B23A4609F001B1A99 /* CNLiveWebView.m */,
177   - 08CA955823A4B492001B1A99 /* CNLiveBaseWebViewController.h */,
178   - 08CA955723A4B492001B1A99 /* CNLiveBaseWebViewController.m */,
179   - 08CA955B23A4B552001B1A99 /* CNLiveInteractionWebController.h */,
180   - 08CA955A23A4B552001B1A99 /* CNLiveInteractionWebController.m */,
181 161 71719F9D1E33DC2100824A3D /* LaunchScreen.storyboard */,
182 162 6003F5A8195388D20070C39A /* Images.xcassets */,
183 163 6003F594195388D20070C39A /* Supporting Files */,
... ... @@ -458,15 +438,11 @@
458 438 isa = PBXSourcesBuildPhase;
459 439 buildActionMask = 2147483647;
460 440 files = (
461   - 08ADA66223A381E100072772 /* CNLiveBaseViewController.m in Sources */,
462   - 08CA955923A4B492001B1A99 /* CNLiveBaseWebViewController.m in Sources */,
463 441 6003F59E195388D20070C39A /* CNLIVEAppDelegate.m in Sources */,
464 442 08827AFE23A8B4AC00EBF18F /* UIViewController+NavigationBarHidden.m in Sources */,
465 443 6003F5A7195388D20070C39A /* CNLIVEViewController.m in Sources */,
466   - 08CA955C23A4B552001B1A99 /* CNLiveInteractionWebController.m in Sources */,
467 444 6003F59A195388D20070C39A /* main.m in Sources */,
468 445 08CA955023A47090001B1A99 /* CNLiveBaseNavigationController.m in Sources */,
469   - 08CA954D23A4609F001B1A99 /* CNLiveWebView.m in Sources */,
470 446 );
471 447 runOnlyForDeploymentPostprocessing = 0;
472 448 };
... ...
Example/CNLiveBalanceModule/CNLIVEAppDelegate.m
... ... @@ -11,9 +11,6 @@
11 11 #import "CNLiveEnvironment.h"
12 12 #import <CNLiveRequestBastKit/CNLiveNetworking.h>
13 13 #import "CNLiveBalanceController.h"
14   -#import "CNLiveBaseViewController.h"
15   -#import "CNLiveBaseWebViewController.h"
16   -#import "CNLiveInteractionWebController.h"
17 14 #import "CNLIVEViewController.h"
18 15  
19 16 @implementation CNLIVEAppDelegate
... ... @@ -67,7 +64,7 @@
67 64 [[NSUserDefaults standardUserDefaults] setObject:@"RkFYeLkl/u5S7tW8UcOkT3rfLTP/Ua8NIkdEsKlcolvl/yxTMNbAYXmmJyhKGpkj" forKey:@"CNLiveAuthToken"];
68 65  
69 66 // CNLiveBaseViewController *vc = [[CNLiveBaseViewController alloc] init];
70   - CNLiveBalanceController *vc = [[CNLiveBalanceController alloc] initWithType:@"2" ID:CNUserShareModel.uid];
  67 + CNLiveBalanceController *vc = [[CNLiveBalanceController alloc] initWithType:@"1" ID:CNUserShareModel.uid];
71 68 // CNLIVEViewController *vc = [[CNLIVEViewController alloc] initWithUrl:@"http://www.baidu.com" title:@"asdasd" closeHidden:NO];
72 69  
73 70 // CNLIVEViewController *vc = [[CNLIVEViewController alloc] initWithUrl:@"http://wjjh5test.cnlive.com/cnComplaint.html" title:@"" closeHidden:NO];
... ...
Example/CNLiveBalanceModule/CNLIVEViewController.h
... ... @@ -6,9 +6,9 @@
6 6 // Copyright (c) 2019 153993236@qq.com. All rights reserved.
7 7 //
8 8  
9   -#import "CNLiveInteractionWebController.h"
  9 +#import <UIKit/UIKit.h>
10 10  
11   -@interface CNLIVEViewController : CNLiveInteractionWebController
  11 +@interface CNLIVEViewController : UIViewController
12 12  
13 13  
14 14 @end
... ...
Example/CNLiveBalanceModule/CNLIVEViewController.m
... ... @@ -7,48 +7,12 @@
7 7 //
8 8  
9 9 #import "CNLIVEViewController.h"
10   -#import "WKWebViewJavascriptBridge.h"
11   -#import "CNLiveWebView.h"
12 10  
13 11 @interface CNLIVEViewController ()
14 12  
15 13 @end
16 14  
17 15 @implementation CNLIVEViewController
18   -#pragma mark - 交互
19   -- (void)interaction {
20   - [super interaction];
21   - [self.bridge registerHandler:@"wjjHelpAndFeedbackImage" handler:^(id data, WVJBResponseCallback responseCallback) {
22   - NSLog(@"ObjC Echo called with: %@", data);
23   - responseCallback(data);
24   - }];
25   - id dataDic = @{
26   - // @"imagePath": imagePath,
27   - @"image" : @"asd"
28   - };
29   - // 帮助与反馈->产品建议:App提交图片数据给h5展示
30   - [self.bridge callHandler:@"wjjCommitImageToJS" data:dataDic responseCallback:^(id responseData) {
31   - NSLog(@"ObjC received response: %@", responseData);
32   - }];
33   -}
34   -
35   -#pragma mark - Setter方法
36   -- (void)setUrl:(NSString *)url{
37   - if(!url||[url isEqualToString:@""]) return;
38   - [super setUrl:[NSString stringWithFormat:@"%@?asd",url]];
39   -}
40   -
41   -#pragma mark - CNLiveWebViewDelegate
42   -- (void)webView:(CNLiveWebView *)webView didFinishLoadWithURL:(NSURL *)url {
43   - NSLog(@"CNLIVEViewController - didFinishLoad");
44   - if(self.title.length == 0){
45   - self.title = webView.title;
46   - }
47   -}
48   -
49   -- (void)webView:(CNLiveWebView *)webView didFailLoadWithError:(NSError *)error {
50   -
51   -}
52 16  
53 17 - (void)didReceiveMemoryWarning
54 18 {
... ...
Example/CNLiveBalanceModule/CNLiveBaseViewController.h deleted 100644 → 0
1   -//
2   -// CNLiveBaseViewController.h
3   -// CNLiveBaseClass
4   -//
5   -// Created by CNLive-zxw on 2019/12/13.
6   -// Copyright © 2019 153993236@qq.com. All rights reserved.
7   -//
8   -
9   -#import <UIKit/UIKit.h>
10   -
11   -NS_ASSUME_NONNULL_BEGIN
12   -
13   -@interface CNLiveBaseViewController : UIViewController
14   -// 是否隐藏导航栏
15   -@property (nonatomic, assign) BOOL navigationHidden;
16   -
17   -// 是否开启侧滑返回手势
18   -@property (nonatomic, assign) BOOL interactive;
19   -
20   -// 子类重写添加子视图方法
21   -- (void)createSubViews;
22   -
23   -@end
24   -
25   -NS_ASSUME_NONNULL_END
Example/CNLiveBalanceModule/CNLiveBaseViewController.m deleted 100644 → 0
1   -//
2   -// CNLiveBaseViewController.m
3   -// CNLiveBaseClass
4   -//
5   -// Created by CNLive-zxw on 2019/12/13.
6   -// Copyright © 2019 153993236@qq.com. All rights reserved.
7   -//
8   -
9   -#import "CNLiveBaseViewController.h"
10   -#import "CNLiveNavigationBar.h"
11   -
12   -@interface CNLiveBaseViewController ()
13   -@property (nonatomic, strong) CNLiveNavigationBar *navigationBar;
14   -
15   -@end
16   -
17   -@implementation CNLiveBaseViewController
18   -#pragma mark - 生命周期
19   -- (void)viewWillAppear:(BOOL)animated {
20   - [super viewWillAppear:animated];
21   - self.navigationController.navigationBarHidden = YES;
22   -}
23   -
24   -- (void)viewDidAppear:(BOOL)animated {
25   - [super viewDidAppear:animated];
26   - // 禁止页面左侧滑动返回,注意,如果仅仅需要禁止此单个页面返回,还需要在viewWillDisapper下开放侧滑权限
27   - // 禁用返回手势
28   - if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
29   - self.navigationController.interactivePopGestureRecognizer.enabled = self.interactive;
30   - }
31   -
32   -}
33   -
34   -- (void)viewDidLoad {
35   - [super viewDidLoad];
36   - // Do any additional setup after loading the view.
37   - self.view.backgroundColor = [UIColor whiteColor];
38   - self.automaticallyAdjustsScrollViewInsets = NO;
39   - [self createSubViews];
40   -}
41   -
42   -#pragma mark - UI
43   -- (void)createSubViews{
44   - [self.view addSubview:self.navigationBar];
45   -}
46   -
47   -#pragma mark - Setter方法
48   -- (void)setTitle:(NSString *)title{
49   - [super setTitle:title];
50   - self.navigationBar.title.text = title;
51   -}
52   -
53   -- (void)setNavigationHidden:(BOOL)navigationHidden{
54   - _navigationHidden = navigationHidden;
55   - _navigationBar.hidden = navigationHidden;
56   -}
57   -
58   -/*
59   -#pragma mark - Navigation
60   -
61   -// In a storyboard-based application, you will often want to do a little preparation before navigation
62   -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
63   - // Get the new view controller using [segue destinationViewController].
64   - // Pass the selected object to the new view controller.
65   -}
66   -*/
67   -#pragma mark - 响应方法
68   -- (void)goBack {
69   - if (self.presentingViewController != nil) {
70   - [self dismissViewControllerAnimated:YES completion:nil];
71   - }
72   - else {
73   - [self.navigationController popViewControllerAnimated:YES];
74   - }
75   -}
76   -
77   -#pragma mark - 懒加载
78   -- (CNLiveNavigationBar *)navigationBar {
79   - if (!_navigationBar) {
80   - _navigationBar = [CNLiveNavigationBar navigationBar];
81   - _navigationBar.title.text = self.title;
82   - __weak typeof(self) weakSelf = self;
83   - _navigationBar.onClickLeftButton = ^{
84   - __strong typeof(weakSelf) strongSelf = weakSelf;
85   - if(!strongSelf) return ;
86   - [strongSelf goBack];
87   - };
88   - }
89   - return _navigationBar;
90   -}
91   -
92   -@end
Example/CNLiveBalanceModule/CNLiveBaseWebViewController.h deleted 100644 → 0
1   -//
2   -// CNLiveBaseWebViewController.h
3   -// CNLiveBaseClass
4   -//
5   -// Created by CNLive-zxw on 2019/12/7.
6   -// Copyright © 2019 153993236@qq.com. All rights reserved.
7   -//
8   -
9   -/*
10   - * 没有交互的WebView
11   - */
12   -
13   -#import "CNLiveBaseViewController.h"
14   -
15   -NS_ASSUME_NONNULL_BEGIN
16   -@class CNLiveWebView;
17   -
18   -@interface CNLiveBaseWebViewController : CNLiveBaseViewController
19   -@property (nonatomic, strong) CNLiveWebView *webView;
20   -@property (nonatomic, copy) NSString *url;
21   -
22   -- (instancetype)initWithUrl:(NSString *)url;
23   -- (instancetype)initWithUrl:(NSString *)url title:(nullable NSString *)title;
24   -- (instancetype)initWithUrl:(NSString *)url title:(nullable NSString *)title closeHidden:(BOOL)closeHidden;
25   -
26   -- (instancetype)init NS_UNAVAILABLE;
27   -+ (instancetype)new NS_UNAVAILABLE;
28   -
29   -@end
30   -
31   -NS_ASSUME_NONNULL_END
Example/CNLiveBalanceModule/CNLiveBaseWebViewController.m deleted 100644 → 0
1   -//
2   -// CNLiveBaseWebViewController.m
3   -// CNLiveBaseClass
4   -//
5   -// Created by CNLive-zxw on 2019/12/7.
6   -// Copyright © 2019 153993236@qq.com. All rights reserved.
7   -//
8   -
9   -#import "CNLiveBaseWebViewController.h"
10   -#import <WebKit/WebKit.h>
11   -#import "QMUIKit.h"
12   -#import "CNLiveCategory.h"
13   -#import "CNLiveWebView.h"
14   -#import "CNLiveNavigationBar.h"
15   -
16   -@interface CNLiveBaseWebViewController ()<CNLiveWebViewDelegate>
17   -@property (nonatomic, strong) UIButton *closeBtn;
18   -@property (nonatomic, assign) BOOL closeHidden;
19   -
20   -@end
21   -
22   -@implementation CNLiveBaseWebViewController
23   -static const NSInteger margin = 10;
24   -
25   -#pragma mark - 初始化
26   -- (instancetype)initWithUrl:(NSString *)url{
27   - return [self initWithUrl:url title:@"" closeHidden:YES];
28   -}
29   -- (instancetype)initWithUrl:(NSString *)url title:(nullable NSString *)title{
30   - return [self initWithUrl:url title:title closeHidden:YES];
31   -}
32   -- (instancetype)initWithUrl:(NSString *)url title:(nullable NSString *)title closeHidden:(BOOL)closeHidden {
33   - self = [super init];
34   - if (self) {
35   - self.url = url;
36   - self.title = title;
37   - self.closeHidden = closeHidden;
38   - }
39   - return self;
40   -}
41   -
42   -#pragma mark - Setter方法
43   -- (void)setUrl:(NSString *)url{
44   - if(!url||[url isEqualToString:@""]) return;
45   - _url = url;
46   -}
47   -
48   -- (NSString *)editHtml:(NSString *)url{
49   - return [NSString stringWithFormat:@"<div style=\"font-size:45px\">%@</div>",url];
50   -}
51   -
52   -#pragma mark - 生命周期
53   -- (void)viewDidLoad {
54   - [super viewDidLoad];
55   - if ([_url hasPrefix:@"http://"]||[_url hasPrefix:@"https://"]) {
56   - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:_url] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10.0];
57   - [self.webView loadRequest:request];
58   -
59   - } else {
60   - [self.webView loadHTMLString:[self editHtml:_url]];
61   - }
62   -}
63   -
64   -- (void)createSubViews {
65   - [super createSubViews];
66   - if(!self.closeHidden&&!self.navigationHidden){
67   - [self.view addSubview:self.closeBtn];
68   - }
69   - [self.view addSubview:self.webView];
70   -}
71   -
72   -#pragma mark - CNLiveWebViewDelegate
73   -- (void)webView:(CNLiveWebView *)webView didFinishLoadWithURL:(NSURL *)url {
74   - NSLog(@"CNLiveWebViewController - didFinishLoad");
75   - if(self.title.length == 0){
76   - self.title = webView.title;
77   - }
78   -}
79   -
80   -- (void)webView:(CNLiveWebView *)webView didFailLoadWithError:(NSError *)error{
81   -
82   -}
83   -
84   -#pragma mark - 响应方法
85   -//回退goBack
86   -- (void)goBack {
87   - if ([self.webView canGoBack]) {
88   - [self.webView goBack];
89   - }
90   - else {
91   - [self closeDidClicked];
92   - }
93   -}
94   -
95   -//关闭pop
96   -- (void)closeDidClicked {
97   - if (self.presentingViewController != nil) {
98   - [self dismissViewControllerAnimated:YES completion:nil];
99   - }
100   - else {
101   - [self.navigationController popViewControllerAnimated:YES];
102   - }
103   -}
104   -
105   -/*
106   -#pragma mark - Navigation
107   -
108   -// In a storyboard-based application, you will often want to do a little preparation before navigation
109   -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
110   - // Get the new view controller using [segue destinationViewController].
111   - // Pass the selected object to the new view controller.
112   -}
113   -*/
114   -
115   -#pragma mark - 懒加载
116   -- (UIButton *)closeBtn{
117   - if(!_closeBtn){
118   - _closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
119   - _closeBtn.adjustsImageWhenHighlighted = NO;
120   - _closeBtn.frame = CGRectMake(NavigationBarHeight+margin, StatusBarHeight, NavigationBarHeight, NavigationBarHeight);
121   - UIImage *image = [self getImageWithImageName:@"cnlive_black_close" bundleName:@"CNLiveCustomControl" targetClass:[CNLiveNavigationBar class]];
122   - [_closeBtn setImage:[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
123   - [_closeBtn addTarget:self action:@selector(closeDidClicked) forControlEvents:UIControlEventTouchUpInside];
124   - [_closeBtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
125   - _closeBtn.hidden = self.closeHidden;
126   - }
127   - return _closeBtn;
128   -}
129   -
130   -- (CNLiveWebView *)webView{
131   - if(!_webView){
132   - _webView = [CNLiveWebView webViewWithFrame:CGRectMake(0, NavigationContentTop, SCREEN_WIDTH, SCREEN_HEIGHT-NavigationContentTop)];
133   - _webView.delegate = self;
134   - }
135   - return _webView;
136   -}
137   -
138   -@end
Example/CNLiveBalanceModule/CNLiveInteractionWebController.h deleted 100644 → 0
1   -//
2   -// CNLiveInteractionWebController.h
3   -// CNLiveBaseClass
4   -//
5   -// Created by CNLive-zxw on 2019/12/14.
6   -// Copyright © 2019 153993236@qq.com. All rights reserved.
7   -//
8   -
9   -/*
10   - * 有交互的WebView
11   - */
12   -
13   -#import "CNLiveBaseWebViewController.h"
14   -
15   -NS_ASSUME_NONNULL_BEGIN
16   -@class WKWebViewJavascriptBridge;
17   -
18   -@interface CNLiveInteractionWebController : CNLiveBaseWebViewController
19   -@property (nonatomic, strong) WKWebViewJavascriptBridge *bridge;
20   -
21   -/*
22   - 注意:初始化方法
23   - - (instancetype)initWithUrl:(NSString *)url;
24   - - (instancetype)initWithUrl:(NSString *)url title:(nullable NSString *)title;
25   - - (instancetype)initWithUrl:(NSString *)url title:(nullable NSString *)title closeHidden:(BOOL)closeHidden;
26   - */
27   -
28   -
29   -/*
30   - * 子类重写添加交互方法
31   - */
32   -- (void)interaction;
33   -
34   -@end
35   -
36   -NS_ASSUME_NONNULL_END
Example/CNLiveBalanceModule/CNLiveInteractionWebController.m deleted 100644 → 0
1   -//
2   -// CNLiveInteractionWebController.m
3   -// CNLiveBaseClass
4   -//
5   -// Created by CNLive-zxw on 2019/12/14.
6   -// Copyright © 2019 153993236@qq.com. All rights reserved.
7   -//
8   -
9   -#import "CNLiveInteractionWebController.h"
10   -#import "WKWebViewJavascriptBridge.h"
11   -#import "CNLiveWebView.h"
12   -
13   -@interface CNLiveInteractionWebController ()
14   -
15   -@end
16   -
17   -@implementation CNLiveInteractionWebController
18   -
19   -- (void)createSubViews {
20   - [super createSubViews];
21   - [self interaction];
22   -}
23   -
24   -- (void)interaction {
25   - [WKWebViewJavascriptBridge enableLogging];
26   - self.bridge = [WKWebViewJavascriptBridge bridgeForWebView:self.webView.wkWebView];
27   - [self.bridge setWebViewDelegate:self.webView];
28   -}
29   -
30   -#pragma mark - CNLiveWebViewDelegate
31   -- (void)webView:(CNLiveWebView *)webView didFinishLoadWithURL:(NSURL *)url {
32   - NSLog(@"CNLiveWebInteractionController - didFinishLoad");
33   - if(self.title.length == 0){
34   - self.title = webView.title;
35   - }
36   -
37   -}
38   -
39   -- (void)webView:(CNLiveWebView *)webView didFailLoadWithError:(NSError *)error{
40   -
41   -}
42   -
43   -/*
44   -#pragma mark - Navigation
45   -
46   -// In a storyboard-based application, you will often want to do a little preparation before navigation
47   -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
48   - // Get the new view controller using [segue destinationViewController].
49   - // Pass the selected object to the new view controller.
50   -}
51   -*/
52   -
53   -@end
Example/CNLiveBalanceModule/CNLiveWebView.h deleted 100755 → 0
1   -//
2   -// CNLiveWebView.h
3   -// CNLiveBaseClass
4   -//
5   -// Created by CNLive-zxw on 2019/9/12.
6   -// Copyright © 2019 153993236@qq.com. All rights reserved.
7   -//
8   -
9   -/*
10   - * 自定义WebView
11   - */
12   -
13   -#import <UIKit/UIKit.h>
14   -#import <WebKit/WebKit.h>
15   -
16   -NS_ASSUME_NONNULL_BEGIN
17   -@class CNLiveWebView;
18   -
19   -@protocol CNLiveWebViewDelegate <NSObject>
20   -@optional
21   -/** 页面开始加载时调用 */
22   -- (void)webViewDidStartLoad:(CNLiveWebView *)webView;
23   -/** 内容开始返回时调用 */
24   -- (void)webView:(CNLiveWebView *)webView didCommitWithURL:(NSURL *)url;
25   -/** 页面加载失败时调用 */
26   -- (void)webView:(CNLiveWebView *)webView didFinishLoadWithURL:(NSURL *)url;
27   -/** 页面加载完成之后调用 */
28   -- (void)webView:(CNLiveWebView *)webView didFailLoadWithError:(NSError *)error;
29   -
30   -@end
31   -
32   -@interface CNLiveWebView : UIView
33   -@property (nonatomic, strong) WKWebView *wkWebView;
34   -@property (nonatomic, strong) UIProgressView *progressView;
35   -
36   -/** CNLiveWebViewDelegate */
37   -@property (nonatomic, weak) id<CNLiveWebViewDelegate> delegate;
38   -/** 进度条颜色(默认蓝色) */
39   -@property (nonatomic, strong) UIColor *progressViewColor;
40   -/** 导航栏标题 */
41   -@property (nonatomic, copy) NSString *title;
42   -
43   -@property (nonatomic, readonly) BOOL canGoBack;
44   -/** 向后 */
45   -- (nullable WKNavigation *)goBack;
46   -
47   -@property (nonatomic, readonly) BOOL canGoForward;
48   -/** 向前 */
49   -- (nullable WKNavigation *)goForward;
50   -/** 刷新数据 */
51   -- (void)reloadData;
52   -
53   -/** 类方法创建 XWWebView */
54   -+ (instancetype)webViewWithFrame:(CGRect)frame;
55   -/** 加载 web */
56   -- (void)loadRequest:(NSURLRequest *)request;
57   -/** 加载 HTML */
58   -- (void)loadHTMLString:(NSString *)HTMLString;
59   -
60   -@end
61   -NS_ASSUME_NONNULL_END
Example/CNLiveBalanceModule/CNLiveWebView.m deleted 100755 → 0
1   -//
2   -// CNLiveWebView.h
3   -// CNLiveBaseClass
4   -//
5   -// Created by CNLive-zxw on 2019/9/12.
6   -// Copyright © 2019 153993236@qq.com. All rights reserved.
7   -//
8   -
9   -#import "CNLiveWebView.h"
10   -#import "QMUIKit.h"
11   -
12   -@interface CNLiveWebView () <WKNavigationDelegate, WKUIDelegate>
13   -
14   -@end
15   -
16   -@implementation CNLiveWebView
17   -static CGFloat const progressViewHeight = 1;
18   -
19   -#pragma mark - 初始化
20   -- (instancetype)initWithFrame:(CGRect)frame {
21   - if (self = [super initWithFrame:frame]) {
22   - if (@available(iOS 11, *)) {
23   - self.wkWebView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic;
24   - }
25   - [self addSubview:self.progressView];
26   - [self addSubview:self.wkWebView];
27   - }
28   - return self;
29   -}
30   -
31   -+ (instancetype)webViewWithFrame:(CGRect)frame {
32   - return [[self alloc] initWithFrame:frame];
33   -}
34   -
35   -// dealloc
36   -- (void)dealloc {
37   - [_wkWebView stopLoading];
38   - [_wkWebView removeObserver:self forKeyPath:NSStringFromSelector(@selector(estimatedProgress))];
39   - _wkWebView.navigationDelegate = nil;
40   - _wkWebView = nil;
41   -}
42   -
43   -#pragma mark - Setter方法
44   -- (void)setProgressViewColor:(UIColor *)progressViewColor {
45   - _progressViewColor = progressViewColor;
46   - if (progressViewColor) {
47   - _progressView.tintColor = progressViewColor;
48   - }
49   -}
50   -
51   -#pragma mark - Getter方法
52   -- (BOOL)canGoBack{
53   - return self.wkWebView.goBack;
54   -}
55   -
56   -- (BOOL)canGoForward{
57   - return self.wkWebView.canGoForward;
58   -}
59   -
60   -#pragma mark - 工具方法
61   -// 向后
62   -- (nullable WKNavigation *)goBack{
63   - return [self.wkWebView goBack];
64   -}
65   -// 向前
66   -- (nullable WKNavigation *)goForward{
67   - return [self.wkWebView goForward];
68   -}
69   -// 刷新数据
70   -- (void)reloadData {
71   - [self.wkWebView reload];
72   -}
73   -// 加载 web
74   -- (void)loadRequest:(NSURLRequest *)request {
75   - [self.wkWebView loadRequest:request];
76   -}
77   -// 加载 HTML
78   -- (void)loadHTMLString:(NSString *)HTMLString {
79   - [self.wkWebView loadHTMLString:HTMLString baseURL:nil];
80   -}
81   -
82   -#pragma mark - KVO
83   -- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
84   - if ([keyPath isEqualToString:NSStringFromSelector(@selector(estimatedProgress))] && object == self.wkWebView) {
85   - self.progressView.alpha = 1.0;
86   - BOOL animated = self.wkWebView.estimatedProgress > self.progressView.progress;
87   - [self.progressView setProgress:self.wkWebView.estimatedProgress animated:animated];
88   - if(self.wkWebView.estimatedProgress >= 0.97) {
89   - [UIView animateWithDuration:0.1 delay:0.3 options:UIViewAnimationOptionCurveEaseOut animations:^{
90   - self.progressView.alpha = 0.0;
91   - } completion:^(BOOL finished) {
92   - [self.progressView setProgress:0.0 animated:NO];
93   - }];
94   - }
95   - } else {
96   - [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
97   - }
98   -}
99   -
100   -#pragma mark - WKNavigationDelegate
101   -// 在发送请求之前,决定是否跳转
102   -- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler{
103   - //允许跳转
104   - decisionHandler(WKNavigationActionPolicyAllow);
105   -}
106   -// 在收到响应后,决定是否跳转
107   -- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler{
108   - //允许跳转
109   - decisionHandler(WKNavigationResponsePolicyAllow);
110   - //不允许跳转
111   - //decisionHandler(WKNavigationResponsePolicyCancel);
112   -}
113   -// 页面开始加载时调用
114   -- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation {
115   - if (self.delegate && [self.delegate respondsToSelector:@selector(webViewDidStartLoad:)]) {
116   - [self.delegate webViewDidStartLoad:self];
117   - }
118   -}
119   -// 当内容开始返回时调用
120   -- (void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation {
121   - if (self.delegate && [self.delegate respondsToSelector:@selector(webView:didCommitWithURL:)]) {
122   - [self.delegate webView:self didCommitWithURL:self.wkWebView.URL];
123   - }
124   -}
125   -// 页面加载完成之后调用
126   -- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
127   - if(!self.title){
128   - self.title = self.wkWebView.title;
129   - }
130   - if (self.delegate && [self.delegate respondsToSelector:@selector(webView:didFinishLoadWithURL:)]) {
131   - [self.delegate webView:self didFinishLoadWithURL:self.wkWebView.URL];
132   - }
133   - self.progressView.alpha = 0.0;
134   -}
135   -// 页面加载失败时调用
136   -- (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error {
137   - if (self.delegate && [self.delegate respondsToSelector:@selector(webView:didFailLoadWithError:)]) {
138   - [self.delegate webView:self didFailLoadWithError:error];
139   - }
140   - self.progressView.alpha = 0.0;
141   -}
142   -// 页面加载失败时调用
143   -- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(null_unspecified WKNavigation *)navigation withError:(nonnull NSError *)error{
144   - if (self.delegate && [self.delegate respondsToSelector:@selector(webView:didFailLoadWithError:)]) {
145   - [self.delegate webView:self didFailLoadWithError:error];
146   - }
147   - self.progressView.alpha = 0.0;
148   -}
149   -// 接收到服务器跳转请求之后调用(重定向)
150   -- (void)webView:(WKWebView *)webView didReceiveServerRedirectForProvisionalNavigation:(WKNavigation *)navigation{
151   -
152   -}
153   -
154   -#pragma mark - 懒加载
155   -- (WKWebView *)wkWebView {
156   - if (!_wkWebView) {
157   - NSMutableString *javascript = [NSMutableString string];
158   - [javascript appendString:@"document.documentElement.style.webkitTouchCallout='none';"];//禁止长按
159   - [javascript appendString:@"document.documentElement.style.webkitUserSelect='none';"];//禁止选择
160   - WKUserScript *noneSelectScript = [[WKUserScript alloc] initWithSource:javascript injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES];
161   - WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
162   - configuration.allowsInlineMediaPlayback = YES;
163   - WKPreferences *preferences = [WKPreferences new];
164   - //很重要,如果没有设置这个则不会回调createWebViewWithConfiguration方法,也不会回应window.open()方法
165   - preferences.javaScriptCanOpenWindowsAutomatically = YES;
166   - configuration.preferences = preferences;
167   - _wkWebView = [[WKWebView alloc] initWithFrame:CGRectMake(0, progressViewHeight, self.frame.size.width, self.frame.size.height-progressViewHeight) configuration:configuration];
168   - [_wkWebView.configuration.userContentController addUserScript:noneSelectScript];
169   - _wkWebView.allowsLinkPreview = NO;
170   - _wkWebView.UIDelegate = self;
171   - _wkWebView.navigationDelegate = self;
172   - [_wkWebView addObserver:self forKeyPath:NSStringFromSelector(@selector(estimatedProgress)) options:0 context:nil];
173   - }
174   - return _wkWebView;
175   -}
176   -
177   -- (UIProgressView *)progressView {
178   - if (!_progressView) {
179   - _progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];
180   - _progressView.trackTintColor = [UIColor clearColor];
181   - // 高度默认有导航栏且有穿透效果
182   - _progressView.frame = CGRectMake(0, 0, self.frame.size.width, progressViewHeight);
183   - // 设置进度条颜色
184   - _progressView.tintColor = [UIColor colorWithRed:19/255.0 green:204/255.0 blue:12/255.0 alpha:1.0];
185   - _progressView.progressTintColor = [UIColor colorWithRed:19/255.0 green:204/255.0 blue:12/255.0 alpha:1.0];
186   - }
187   - return _progressView;
188   -}
189   -
190   -@end