Commit d9f394cb25fe8fed441abfe0ae7ba2a8a0f2b6bb
1 parent
ea648526
no message
Showing
8 changed files
with
95 additions
and
340 deletions
CNLiveUserAgreementManager.podspec
| @@ -45,7 +45,10 @@ TODO: 网家家-用户协议管理类. | @@ -45,7 +45,10 @@ TODO: 网家家-用户协议管理类. | ||
| 45 | # 数据请求 | 45 | # 数据请求 |
| 46 | s.dependency 'CNLiveRequestBastKit' | 46 | s.dependency 'CNLiveRequestBastKit' |
| 47 | 47 | ||
| 48 | - #类别 | 48 | + # 类别 |
| 49 | s.dependency 'CNLiveCategory' | 49 | s.dependency 'CNLiveCategory' |
| 50 | + | ||
| 51 | + # 基类 | ||
| 52 | + s.dependency 'CNLiveBaseClass' | ||
| 50 | 53 | ||
| 51 | end | 54 | end |
CNLiveUserAgreementManager/Classes/CNLiveUserAgreementController.h
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveUserAgreementController.h | ||
| 3 | +// CNLiveUserAgreementManager | ||
| 4 | +// | ||
| 5 | +// Created by 153993236@qq.com on 04/13/2019. | ||
| 6 | +// Copyright (c) 2019 153993236@qq.com. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import "CNLiveInteractionWebController.h" | ||
| 10 | + | ||
| 11 | +NS_ASSUME_NONNULL_BEGIN | ||
| 12 | + | ||
| 13 | +@interface CNLiveUserAgreementController : CNLiveInteractionWebController | ||
| 14 | + | ||
| 15 | + | ||
| 16 | +@end | ||
| 17 | + | ||
| 18 | +NS_ASSUME_NONNULL_END |
CNLiveUserAgreementManager/Classes/CNLiveUserAgreementController.m
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveUserAgreementController.h | ||
| 3 | +// CNLiveUserAgreementManager | ||
| 4 | +// | ||
| 5 | +// Created by 153993236@qq.com on 04/13/2019. | ||
| 6 | +// Copyright (c) 2019 153993236@qq.com. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import "CNLiveUserAgreementController.h" | ||
| 10 | +#import "WKWebViewJavascriptBridge.h" | ||
| 11 | +#import "CNLiveWebView.h" | ||
| 12 | + | ||
| 13 | +@interface CNLiveUserAgreementController () | ||
| 14 | + | ||
| 15 | +@end | ||
| 16 | + | ||
| 17 | +@implementation CNLiveUserAgreementController | ||
| 18 | + | ||
| 19 | +#pragma mark - 交互 | ||
| 20 | +- (void)interaction { | ||
| 21 | + [super interaction]; | ||
| 22 | + [self.bridge registerHandler:@"wjjHelpAndFeedbackImage" handler:^(id data, WVJBResponseCallback responseCallback) { | ||
| 23 | + NSLog(@"ObjC Echo called with: %@", data); | ||
| 24 | + responseCallback(data); | ||
| 25 | + }]; | ||
| 26 | + id dataDic = @{ | ||
| 27 | + // @"imagePath": imagePath, | ||
| 28 | + @"image" : @"asd" | ||
| 29 | + }; | ||
| 30 | + // 帮助与反馈->产品建议:App提交图片数据给h5展示 | ||
| 31 | + [self.bridge callHandler:@"wjjCommitImageToJS" data:dataDic responseCallback:^(id responseData) { | ||
| 32 | + NSLog(@"ObjC received response: %@", responseData); | ||
| 33 | + }]; | ||
| 34 | +} | ||
| 35 | + | ||
| 36 | +#pragma mark - Setter方法 | ||
| 37 | +- (void)setUrl:(NSString *)url{ | ||
| 38 | + if(!url||[url isEqualToString:@""]) return; | ||
| 39 | + [super setUrl:[NSString stringWithFormat:@"%@?asd",url]]; | ||
| 40 | +} | ||
| 41 | + | ||
| 42 | +#pragma mark - CNLiveWebViewDelegate | ||
| 43 | +- (void)webView:(CNLiveWebView *)webView didFinishLoadWithURL:(NSURL *)url { | ||
| 44 | + NSLog(@"CNLIVEViewController - didFinishLoad"); | ||
| 45 | + if(self.title.length == 0){ | ||
| 46 | + self.title = webView.title; | ||
| 47 | + } | ||
| 48 | +} | ||
| 49 | + | ||
| 50 | +- (void)webView:(CNLiveWebView *)webView didFailLoadWithError:(NSError *)error { | ||
| 51 | + | ||
| 52 | +} | ||
| 53 | + | ||
| 54 | +@end |
CNLiveUserAgreementManager/Classes/CNLiveUserAgreementManager.m
| @@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
| 8 | #import "CNLiveUserAgreementManager.h" | 8 | #import "CNLiveUserAgreementManager.h" |
| 9 | #import <CNLiveRequestBastKit/CNLiveNetworking.h> | 9 | #import <CNLiveRequestBastKit/CNLiveNetworking.h> |
| 10 | #import "CNLiveEnvironment.h" | 10 | #import "CNLiveEnvironment.h" |
| 11 | -#import "CNLiveUserAgreementWebController.h" | 11 | +#import "CNLiveUserAgreementController.h" |
| 12 | 12 | ||
| 13 | @interface CNLiveUserAgreementManager() | 13 | @interface CNLiveUserAgreementManager() |
| 14 | 14 | ||
| @@ -343,7 +343,7 @@ static CNLiveUserAgreementManager *_instance = nil; | @@ -343,7 +343,7 @@ static CNLiveUserAgreementManager *_instance = nil; | ||
| 343 | //跟控制器是Navigation | 343 | //跟控制器是Navigation |
| 344 | if ([root isKindOfClass:[UINavigationController class]]){ | 344 | if ([root isKindOfClass:[UINavigationController class]]){ |
| 345 | UINavigationController *nav = (UINavigationController *)root; | 345 | UINavigationController *nav = (UINavigationController *)root; |
| 346 | - CNLiveUserAgreementWebController *vc = [[CNLiveUserAgreementWebController alloc] initWithUrl:url name:name showCloseBtn:isShow]; | 346 | + CNLiveUserAgreementController *vc = [[CNLiveUserAgreementController alloc] initWithUrl:url title:name closeHidden:isShow]; |
| 347 | [nav pushViewController:vc animated:YES]; | 347 | [nav pushViewController:vc animated:YES]; |
| 348 | 348 | ||
| 349 | } | 349 | } |
| @@ -353,15 +353,15 @@ static CNLiveUserAgreementManager *_instance = nil; | @@ -353,15 +353,15 @@ static CNLiveUserAgreementManager *_instance = nil; | ||
| 353 | UIViewController *selected = tab.selectedViewController; | 353 | UIViewController *selected = tab.selectedViewController; |
| 354 | if ([selected isKindOfClass:[UINavigationController class]]){ | 354 | if ([selected isKindOfClass:[UINavigationController class]]){ |
| 355 | UINavigationController *nav = (UINavigationController *)selected; | 355 | UINavigationController *nav = (UINavigationController *)selected; |
| 356 | - CNLiveUserAgreementWebController *vc = [[CNLiveUserAgreementWebController alloc] initWithUrl:url name:name showCloseBtn:isShow]; | 356 | + CNLiveUserAgreementController *vc = [[CNLiveUserAgreementController alloc] initWithUrl:url title:name closeHidden:isShow]; |
| 357 | [nav pushViewController:vc animated:YES]; | 357 | [nav pushViewController:vc animated:YES]; |
| 358 | }else{ | 358 | }else{ |
| 359 | - CNLiveUserAgreementWebController *vc = [[CNLiveUserAgreementWebController alloc] initWithUrl:url name:name showCloseBtn:isShow]; | 359 | + CNLiveUserAgreementController *vc = [[CNLiveUserAgreementController alloc] initWithUrl:url title:name closeHidden:isShow]; |
| 360 | [root presentViewController:vc animated:YES completion:nil]; | 360 | [root presentViewController:vc animated:YES completion:nil]; |
| 361 | } | 361 | } |
| 362 | 362 | ||
| 363 | }else{ | 363 | }else{ |
| 364 | - CNLiveUserAgreementWebController *vc = [[CNLiveUserAgreementWebController alloc] initWithUrl:url name:name showCloseBtn:isShow]; | 364 | + CNLiveUserAgreementController *vc = [[CNLiveUserAgreementController alloc] initWithUrl:url title:name closeHidden:isShow]; |
| 365 | [root presentViewController:vc animated:YES completion:nil]; | 365 | [root presentViewController:vc animated:YES completion:nil]; |
| 366 | 366 | ||
| 367 | } | 367 | } |
CNLiveUserAgreementManager/Classes/CNLiveUserAgreementWebController.h deleted
100644 → 0
| 1 | -// | ||
| 2 | -// CNLiveUserAgreementWebController.h | ||
| 3 | -// CNLiveUserAgreementManager | ||
| 4 | -// | ||
| 5 | -// Created by 153993236@qq.com on 04/13/2019. | ||
| 6 | -// Copyright (c) 2019 153993236@qq.com. All rights reserved. | ||
| 7 | -// | ||
| 8 | - | ||
| 9 | -#import <UIKit/UIKit.h> | ||
| 10 | - | ||
| 11 | -NS_ASSUME_NONNULL_BEGIN | ||
| 12 | - | ||
| 13 | -@interface CNLiveUserAgreementWebController : UIViewController | ||
| 14 | - | ||
| 15 | -/** | ||
| 16 | - * 对象方法 初始化方法 | ||
| 17 | - * @param url url | ||
| 18 | - * @param name 标题 | ||
| 19 | - * 注意:默认没有关闭按钮 | ||
| 20 | - */ | ||
| 21 | -- (instancetype)initWithUrl:(NSString *)url name:(nullable NSString *)name; | ||
| 22 | - | ||
| 23 | - | ||
| 24 | -/** | ||
| 25 | - * 对象方法 初始化方法 | ||
| 26 | - * @param url url | ||
| 27 | - * @param name 标题 | ||
| 28 | - * @param isShow 是否显示关闭按钮 | ||
| 29 | - */ | ||
| 30 | -- (instancetype)initWithUrl:(NSString *)url name:(nullable NSString *)name showCloseBtn:(BOOL)isShow; | ||
| 31 | - | ||
| 32 | -@end | ||
| 33 | - | ||
| 34 | -NS_ASSUME_NONNULL_END |
CNLiveUserAgreementManager/Classes/CNLiveUserAgreementWebController.m deleted
100644 → 0
| 1 | -// | ||
| 2 | -// CNLiveUserAgreementWebController.h | ||
| 3 | -// CNLiveUserAgreementManager | ||
| 4 | -// | ||
| 5 | -// Created by 153993236@qq.com on 04/13/2019. | ||
| 6 | -// Copyright (c) 2019 153993236@qq.com. All rights reserved. | ||
| 7 | -// | ||
| 8 | - | ||
| 9 | -#import "CNLiveUserAgreementWebController.h" | ||
| 10 | -#import <WebKit/WebKit.h> | ||
| 11 | -// 环境库 | ||
| 12 | -#import "CNLiveEnvironment.h" | ||
| 13 | -#import "CNLiveCategory.h" | ||
| 14 | - | ||
| 15 | -#import <CNLiveRequestBastKit/CNLiveNetworking.h> | ||
| 16 | - | ||
| 17 | -@interface CNLiveUserAgreementWebController ()<WKUIDelegate, WKNavigationDelegate> | ||
| 18 | -@property (nonatomic, copy) NSString *url; | ||
| 19 | -@property (nonatomic, copy) NSString *name; | ||
| 20 | -@property (nonatomic, assign) BOOL isShow; | ||
| 21 | - | ||
| 22 | -@property (nonatomic, strong) WKWebView *webView; | ||
| 23 | -@property (nonatomic, strong) UIProgressView *processView; | ||
| 24 | -@property (nonatomic, weak) UILabel *titleLabel; | ||
| 25 | - | ||
| 26 | -@property (nonatomic, strong) NSMutableArray *photos;// 上传图片 | ||
| 27 | - | ||
| 28 | -@end | ||
| 29 | - | ||
| 30 | -@implementation CNLiveUserAgreementWebController | ||
| 31 | -static const NSInteger margin = 15; | ||
| 32 | - | ||
| 33 | -#pragma mark - 初始化方法 | ||
| 34 | -- (instancetype)initWithUrl:(NSString *)url name:(nullable NSString *)name{ | ||
| 35 | - return [self initWithUrl:url name:name showCloseBtn:NO]; | ||
| 36 | -} | ||
| 37 | - | ||
| 38 | -- (instancetype)initWithUrl:(NSString *)url name:(nullable NSString *)name showCloseBtn:(BOOL)isShow { | ||
| 39 | - self = [super init]; | ||
| 40 | - if (self) { | ||
| 41 | - self.url = url; | ||
| 42 | - self.name = name; | ||
| 43 | - self.isShow = isShow; | ||
| 44 | - } | ||
| 45 | - return self; | ||
| 46 | -} | ||
| 47 | - | ||
| 48 | -- (void)setName:(NSString *)name{ | ||
| 49 | - _name = name; | ||
| 50 | - _titleLabel.text = name; | ||
| 51 | -} | ||
| 52 | - | ||
| 53 | -#pragma mark - 加载数据 | ||
| 54 | -- (void)loadUrl { | ||
| 55 | - NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:self.url] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:15.0]; | ||
| 56 | - [self.webView loadRequest:theRequest]; | ||
| 57 | -} | ||
| 58 | - | ||
| 59 | -#pragma mark - 生命周期 | ||
| 60 | -- (void)viewWillAppear:(BOOL)animated { | ||
| 61 | - [super viewWillAppear:animated]; | ||
| 62 | - self.navigationController.navigationBarHidden = YES; | ||
| 63 | -} | ||
| 64 | - | ||
| 65 | -- (void)viewWillDisappear:(BOOL)animated { | ||
| 66 | - [super viewWillDisappear:animated]; | ||
| 67 | - self.navigationController.navigationBarHidden = NO; | ||
| 68 | -} | ||
| 69 | - | ||
| 70 | -- (void)viewDidLoad { | ||
| 71 | - [super viewDidLoad]; | ||
| 72 | - self.view.backgroundColor = [UIColor whiteColor]; | ||
| 73 | - if (@available(iOS 11, *)) { | ||
| 74 | - self.webView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic; | ||
| 75 | - } | ||
| 76 | - else { | ||
| 77 | - self.automaticallyAdjustsScrollViewInsets = NO; | ||
| 78 | - } | ||
| 79 | - [self setupNavigationBar]; | ||
| 80 | - [self createSubViews]; | ||
| 81 | - [self loadUrl]; | ||
| 82 | - | ||
| 83 | -} | ||
| 84 | - | ||
| 85 | -- (void)dealloc { | ||
| 86 | - if(TestEnvironment){ | ||
| 87 | - NSLog(@"CNUserLiveAgreementWebController dealloc"); | ||
| 88 | - } | ||
| 89 | - [self.webView stopLoading]; | ||
| 90 | - [self.webView removeObserver:self forKeyPath:@"estimatedProgress"]; | ||
| 91 | - if (!self.name) { | ||
| 92 | - [self.webView removeObserver:self forKeyPath:@"title"]; | ||
| 93 | - } | ||
| 94 | - self.webView.UIDelegate = nil; | ||
| 95 | - self.webView.navigationDelegate = nil; | ||
| 96 | - self.webView = nil; | ||
| 97 | - [self clearWKCache]; | ||
| 98 | - | ||
| 99 | -} | ||
| 100 | - | ||
| 101 | -#pragma mark - 创建导航条 | ||
| 102 | -- (void)setupNavigationBar { | ||
| 103 | - UIView *navView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 44+[UIApplication sharedApplication].statusBarFrame.size.height)]; | ||
| 104 | - navView.backgroundColor = [UIColor clearColor]; | ||
| 105 | - [self.view bringSubviewToFront:navView]; | ||
| 106 | - [self.view addSubview:navView]; | ||
| 107 | - | ||
| 108 | - UIButton *leftBtn = [UIButton buttonWithType:UIButtonTypeCustom]; | ||
| 109 | - leftBtn.adjustsImageWhenHighlighted = NO; | ||
| 110 | - leftBtn.frame = CGRectMake(margin, [UIApplication sharedApplication].statusBarFrame.size.height, 44, 44); | ||
| 111 | - UIImage *leftImage = [self getImageWithImageName:@"web_black_back" bundleName:@"CNLiveUserAgreementManager" targetClass:[CNLiveUserAgreementWebController class]]; | ||
| 112 | - [leftBtn setImage:[leftImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal]; | ||
| 113 | - [leftBtn addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside]; | ||
| 114 | - [leftBtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft]; | ||
| 115 | - [navView addSubview:leftBtn]; | ||
| 116 | - | ||
| 117 | - UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom]; | ||
| 118 | - closeBtn.adjustsImageWhenHighlighted = NO; | ||
| 119 | - closeBtn.frame = CGRectMake(44+margin, [UIApplication sharedApplication].statusBarFrame.size.height, 44, 44); | ||
| 120 | - UIImage *closeImage = [self getImageWithImageName:@"web_black_close" bundleName:@"CNLiveUserAgreementManager" targetClass:[CNLiveUserAgreementWebController class]]; | ||
| 121 | - [closeBtn setImage:[closeImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal]; | ||
| 122 | - [closeBtn addTarget:self action:@selector(closeClick) forControlEvents:UIControlEventTouchUpInside]; | ||
| 123 | - [closeBtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft]; | ||
| 124 | - closeBtn.hidden = !self.isShow; | ||
| 125 | - [navView addSubview:closeBtn]; | ||
| 126 | - | ||
| 127 | - UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(([[UIScreen mainScreen] bounds].size.width - 200)/2.0, [UIApplication sharedApplication].statusBarFrame.size.height, 200, 44)]; | ||
| 128 | - titleLabel.font = [UIFont boldSystemFontOfSize:17]; | ||
| 129 | - titleLabel.textColor = [UIColor blackColor]; | ||
| 130 | - titleLabel.text = self.name; | ||
| 131 | - titleLabel.textAlignment = NSTextAlignmentCenter; | ||
| 132 | - [navView addSubview:titleLabel]; | ||
| 133 | - _titleLabel = titleLabel; | ||
| 134 | - | ||
| 135 | -} | ||
| 136 | - | ||
| 137 | -- (void)createSubViews { | ||
| 138 | - [self.view addSubview:self.webView]; | ||
| 139 | - [self.view addSubview:self.processView]; | ||
| 140 | - | ||
| 141 | - [self.webView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:nil]; | ||
| 142 | - if (!self.name) { | ||
| 143 | - [self.webView addObserver:self forKeyPath:@"title" options:NSKeyValueObservingOptionNew context:NULL]; | ||
| 144 | - } | ||
| 145 | - | ||
| 146 | -} | ||
| 147 | - | ||
| 148 | - | ||
| 149 | -#pragma mark - WKNavigationDelegate | ||
| 150 | -// 在发送请求之前,决定是否跳转 | ||
| 151 | -- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler{ | ||
| 152 | - //允许跳转 | ||
| 153 | - decisionHandler(WKNavigationActionPolicyAllow); | ||
| 154 | - | ||
| 155 | -} | ||
| 156 | - | ||
| 157 | -// 页面开始加载时调用 | ||
| 158 | -- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation{ | ||
| 159 | - | ||
| 160 | -} | ||
| 161 | - | ||
| 162 | -// 在收到响应后,决定是否跳转 | ||
| 163 | -- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler{ | ||
| 164 | - //允许跳转 | ||
| 165 | - decisionHandler(WKNavigationResponsePolicyAllow); | ||
| 166 | - //不允许跳转 | ||
| 167 | - //decisionHandler(WKNavigationResponsePolicyCancel); | ||
| 168 | -} | ||
| 169 | - | ||
| 170 | -// 当内容开始返回时调用 | ||
| 171 | -- (void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation{ | ||
| 172 | - | ||
| 173 | -} | ||
| 174 | - | ||
| 175 | -// 页面加载完成之后调用 | ||
| 176 | -- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{ | ||
| 177 | - | ||
| 178 | -} | ||
| 179 | - | ||
| 180 | -// 页面加载失败时调用 | ||
| 181 | -- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(null_unspecified WKNavigation *)navigation withError:(nonnull NSError *)error{ | ||
| 182 | - NSLog(@"打印这个error%@",error); | ||
| 183 | - | ||
| 184 | -} | ||
| 185 | - | ||
| 186 | -// 接收到服务器跳转请求之后调用(重定向) | ||
| 187 | -- (void)webView:(WKWebView *)webView didReceiveServerRedirectForProvisionalNavigation:(WKNavigation *)navigation{ | ||
| 188 | - | ||
| 189 | -} | ||
| 190 | - | ||
| 191 | -#pragma mark - 响应方法 | ||
| 192 | -//回退goBack | ||
| 193 | -- (void)goBack { | ||
| 194 | - if ([self.webView canGoBack]) { | ||
| 195 | - [self.webView goBack]; | ||
| 196 | - } | ||
| 197 | - else { | ||
| 198 | - [self closeClick]; | ||
| 199 | - } | ||
| 200 | -} | ||
| 201 | - | ||
| 202 | -//关闭pop | ||
| 203 | -- (void)closeClick { | ||
| 204 | - if (self.presentingViewController != nil) { | ||
| 205 | - [self dismissViewControllerAnimated:YES completion:nil]; | ||
| 206 | - | ||
| 207 | - } | ||
| 208 | - else { | ||
| 209 | - [self.navigationController popViewControllerAnimated:YES]; | ||
| 210 | - } | ||
| 211 | -} | ||
| 212 | - | ||
| 213 | -#pragma mark - KVO | ||
| 214 | -- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context { | ||
| 215 | - if ([keyPath isEqualToString:@"estimatedProgress"]) { | ||
| 216 | - if (object == self.webView) { | ||
| 217 | - [self.processView setAlpha:1.0f]; | ||
| 218 | - [self.processView setProgress:self.webView.estimatedProgress animated:YES]; | ||
| 219 | - | ||
| 220 | - if(self.webView.estimatedProgress >= 1.0f) { | ||
| 221 | - | ||
| 222 | - [UIView animateWithDuration:0.3 delay:0.5 options:UIViewAnimationOptionCurveEaseOut animations:^{ | ||
| 223 | - [self.processView setAlpha:0.0f]; | ||
| 224 | - | ||
| 225 | - } completion:^(BOOL finished) { | ||
| 226 | - [self.processView setProgress:0.0f animated:NO]; | ||
| 227 | - | ||
| 228 | - }]; | ||
| 229 | - | ||
| 230 | - } | ||
| 231 | - | ||
| 232 | - } | ||
| 233 | - else { | ||
| 234 | - [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; | ||
| 235 | - } | ||
| 236 | - | ||
| 237 | - } | ||
| 238 | - else if ([keyPath isEqualToString:@"title"]){ | ||
| 239 | - if (object == self.webView) { | ||
| 240 | - if (self.webView.title.length != 0) { | ||
| 241 | - self.name = self.webView.title; | ||
| 242 | - | ||
| 243 | - } | ||
| 244 | - } | ||
| 245 | - else { | ||
| 246 | - [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; | ||
| 247 | - } | ||
| 248 | - } | ||
| 249 | - else { | ||
| 250 | - [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; | ||
| 251 | - | ||
| 252 | - } | ||
| 253 | -} | ||
| 254 | -#pragma mark - 懒加载 | ||
| 255 | -- (WKWebView *)webView{ | ||
| 256 | - if(!_webView){ | ||
| 257 | - WKWebViewConfiguration * configuration = [[WKWebViewConfiguration alloc] init]; | ||
| 258 | - configuration.allowsInlineMediaPlayback = YES; | ||
| 259 | - WKPreferences *preferences = [WKPreferences new]; | ||
| 260 | - preferences.javaScriptCanOpenWindowsAutomatically = YES; | ||
| 261 | - configuration.preferences = preferences; | ||
| 262 | - _webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, [UIApplication sharedApplication].statusBarFrame.size.height+44, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height-([UIApplication sharedApplication].statusBarFrame.size.height+44)) configuration:configuration]; | ||
| 263 | - _webView.UIDelegate = self; | ||
| 264 | - _webView.navigationDelegate = self; | ||
| 265 | - _webView.contentMode = UIViewContentModeScaleAspectFit; | ||
| 266 | - _webView.scrollView.showsHorizontalScrollIndicator = NO; | ||
| 267 | - _webView.scrollView.showsVerticalScrollIndicator = NO; | ||
| 268 | - _webView.allowsBackForwardNavigationGestures = YES; | ||
| 269 | - _webView.allowsLinkPreview = NO; | ||
| 270 | - | ||
| 271 | - } | ||
| 272 | - return _webView; | ||
| 273 | -} | ||
| 274 | - | ||
| 275 | -- (UIProgressView *)processView{ | ||
| 276 | - if(!_processView){ | ||
| 277 | - _processView = [[UIProgressView alloc] initWithFrame:CGRectMake(0, ([UIApplication sharedApplication].statusBarFrame.size.height+44)+0.5, [[UIScreen mainScreen] bounds].size.width, 1)]; | ||
| 278 | - _processView.progressTintColor = [UIColor colorWithRed:19/255.0 green:204/255.0 blue:12/255.0 alpha:1.0]; | ||
| 279 | - _processView.trackTintColor = [UIColor whiteColor]; | ||
| 280 | - } | ||
| 281 | - return _processView; | ||
| 282 | -} | ||
| 283 | - | ||
| 284 | -#pragma mark - 私有方法 | ||
| 285 | -// 清除缓存 | ||
| 286 | -- (void)clearWKCache { | ||
| 287 | - NSArray *types = @[WKWebsiteDataTypeDiskCache,WKWebsiteDataTypeOfflineWebApplicationCache,WKWebsiteDataTypeMemoryCache,WKWebsiteDataTypeIndexedDBDatabases,WKWebsiteDataTypeWebSQLDatabases]; | ||
| 288 | - NSSet *websiteDataTypes = [NSSet setWithArray:types]; | ||
| 289 | - NSDate *dateFrom = [NSDate dateWithTimeIntervalSince1970:0]; | ||
| 290 | - [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:websiteDataTypes modifiedSince:dateFrom completionHandler:^{ | ||
| 291 | - if(TestEnvironment){ | ||
| 292 | - NSLog(@"CNLiveUserAgreementWebController 缓存清理完毕"); | ||
| 293 | - } | ||
| 294 | - }]; | ||
| 295 | - | ||
| 296 | -} | ||
| 297 | - | ||
| 298 | -@end |
Example/CNLiveUserAgreementManager.xcodeproj/project.pbxproj
| @@ -350,18 +350,30 @@ | @@ -350,18 +350,30 @@ | ||
| 350 | inputPaths = ( | 350 | inputPaths = ( |
| 351 | "${PODS_ROOT}/Target Support Files/Pods-CNLiveUserAgreementManager_Example/Pods-CNLiveUserAgreementManager_Example-frameworks.sh", | 351 | "${PODS_ROOT}/Target Support Files/Pods-CNLiveUserAgreementManager_Example/Pods-CNLiveUserAgreementManager_Example-frameworks.sh", |
| 352 | "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework", | 352 | "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework", |
| 353 | + "${BUILT_PRODUCTS_DIR}/CNLiveBaseClass/CNLiveBaseClass.framework", | ||
| 353 | "${BUILT_PRODUCTS_DIR}/CNLiveCategory/CNLiveCategory.framework", | 354 | "${BUILT_PRODUCTS_DIR}/CNLiveCategory/CNLiveCategory.framework", |
| 355 | + "${BUILT_PRODUCTS_DIR}/CNLiveCustomControl/CNLiveCustomControl.framework", | ||
| 354 | "${BUILT_PRODUCTS_DIR}/CNLiveEnvironment/CNLiveEnvironment.framework", | 356 | "${BUILT_PRODUCTS_DIR}/CNLiveEnvironment/CNLiveEnvironment.framework", |
| 355 | "${BUILT_PRODUCTS_DIR}/CNLiveRequestBastKit/CNLiveRequestBastKit.framework", | 357 | "${BUILT_PRODUCTS_DIR}/CNLiveRequestBastKit/CNLiveRequestBastKit.framework", |
| 358 | + "${BUILT_PRODUCTS_DIR}/CNLiveTripartiteManagement/CNLiveTripartiteManagement.framework", | ||
| 356 | "${BUILT_PRODUCTS_DIR}/CNLiveUserAgreementManager/CNLiveUserAgreementManager.framework", | 359 | "${BUILT_PRODUCTS_DIR}/CNLiveUserAgreementManager/CNLiveUserAgreementManager.framework", |
| 360 | + "${BUILT_PRODUCTS_DIR}/Masonry/Masonry.framework", | ||
| 361 | + "${BUILT_PRODUCTS_DIR}/QMUIKit/QMUIKit.framework", | ||
| 362 | + "${BUILT_PRODUCTS_DIR}/WebViewJavascriptBridge/WebViewJavascriptBridge.framework", | ||
| 357 | ); | 363 | ); |
| 358 | name = "[CP] Embed Pods Frameworks"; | 364 | name = "[CP] Embed Pods Frameworks"; |
| 359 | outputPaths = ( | 365 | outputPaths = ( |
| 360 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AFNetworking.framework", | 366 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AFNetworking.framework", |
| 367 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBaseClass.framework", | ||
| 361 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCategory.framework", | 368 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCategory.framework", |
| 369 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCustomControl.framework", | ||
| 362 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveEnvironment.framework", | 370 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveEnvironment.framework", |
| 363 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveRequestBastKit.framework", | 371 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveRequestBastKit.framework", |
| 372 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveTripartiteManagement.framework", | ||
| 364 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserAgreementManager.framework", | 373 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserAgreementManager.framework", |
| 374 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Masonry.framework", | ||
| 375 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/QMUIKit.framework", | ||
| 376 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/WebViewJavascriptBridge.framework", | ||
| 365 | ); | 377 | ); |
| 366 | runOnlyForDeploymentPostprocessing = 0; | 378 | runOnlyForDeploymentPostprocessing = 0; |
| 367 | shellPath = /bin/sh; | 379 | shellPath = /bin/sh; |
Example/CNLiveUserAgreementManager/CNLiveViewController.m
| @@ -10,7 +10,7 @@ | @@ -10,7 +10,7 @@ | ||
| 10 | #import "CNLiveEnvironment.h" | 10 | #import "CNLiveEnvironment.h" |
| 11 | 11 | ||
| 12 | #import "CNLiveUserAgreementManager.h" | 12 | #import "CNLiveUserAgreementManager.h" |
| 13 | -#import "CNLiveUserAgreementWebController.h" | 13 | +#import "CNLiveUserAgreementController.h" |
| 14 | 14 | ||
| 15 | @interface CNLiveViewController () | 15 | @interface CNLiveViewController () |
| 16 | 16 | ||
| @@ -38,7 +38,7 @@ | @@ -38,7 +38,7 @@ | ||
| 38 | // [CNLiveUserAgreementManager jumpToAgreementH5WithType:CNLiveUserAgreementCancellation]; | 38 | // [CNLiveUserAgreementManager jumpToAgreementH5WithType:CNLiveUserAgreementCancellation]; |
| 39 | // [CNLiveUserAgreementManager jumpToAgreementH5WithString:@"yhxy"]; | 39 | // [CNLiveUserAgreementManager jumpToAgreementH5WithString:@"yhxy"]; |
| 40 | [CNLiveUserAgreementManager getAgreementH5WithType:CNLiveUserAgreementCancellation success:^(NSString * _Nonnull h5, NSString * _Nonnull title, BOOL isShow) { | 40 | [CNLiveUserAgreementManager getAgreementH5WithType:CNLiveUserAgreementCancellation success:^(NSString * _Nonnull h5, NSString * _Nonnull title, BOOL isShow) { |
| 41 | - CNLiveUserAgreementWebController *vc = [[CNLiveUserAgreementWebController alloc] initWithUrl:h5 name:title showCloseBtn:NO]; | 41 | + CNLiveUserAgreementController *vc = [[CNLiveUserAgreementController alloc] initWithUrl:h5 title:title closeHidden:NO]; |
| 42 | [self.navigationController pushViewController:vc animated:YES]; | 42 | [self.navigationController pushViewController:vc animated:YES]; |
| 43 | 43 | ||
| 44 | } failure:^(NSError * _Nonnull error) { | 44 | } failure:^(NSError * _Nonnull error) { |