Commit 1814d7235385d5b40676bcc81f2f403115f724fb

Authored by zhangxiaowen
1 parent 91798ff4

no message

CNLiveQrCodeModule/Classes/Controller/CNLiveScanResultController.m
... ... @@ -52,8 +52,8 @@
52 52 #pragma mark - 代理
53 53 - (void)webView:(CNLiveWebView *)webView didFinishLoadWithURL:(NSURL *)url {
54 54 NSLog(@"didFinishLoad");
55   - if(webView.navigationItemTitle.length != 0){
56   - self.navigationBar.title.text = webView.navigationItemTitle;
  55 + if(webView.title.length != 0){
  56 + self.navigationBar.title.text = webView.title;
57 57 }else{
58 58 self.navigationBar.title.text = @"识别结果";
59 59  
... ... @@ -83,7 +83,6 @@
83 83 - (CNLiveWebView *)webView {
84 84 if (!_webView) {
85 85 _webView = [CNLiveWebView webViewWithFrame:CGRectMake(0, NavigationContentTop, SCREEN_WIDTH, SCREEN_HEIGHT-NavigationContentTop)];
86   - _webView.isNavigationBarOrTranslucent = NO;
87 86 _webView.delegate = self;
88 87 }
89 88 return _webView;
... ...
CNLiveQrCodeModule/Classes/View/CNLiveWebView.h deleted 100755 → 0
1   -//
2   -// CNLiveWebView.h
3   -// CNLiveQrCodeModule
4   -//
5   -// Created by 153993236@qq.com on 11/12/2019.
6   -// Copyright (c) 2019 153993236@qq.com. All rights reserved.
7   -//
8   -// CNLiveWebView 使用注意点:
9   -// 如果 self.navigationController.navigationBar.translucent = NO;或者导航栏不存在; 那么 XWWebView 的 isNavigationBarOrTranslucent属性 必须设置 NO)
10   -
11   -#import <UIKit/UIKit.h>
12   -@class CNLiveWebView;
13   -
14   -@protocol CNLiveWebViewDelegate <NSObject>
15   -@optional
16   -/** 页面开始加载时调用 */
17   -- (void)webViewDidStartLoad:(CNLiveWebView *)webView;
18   -/** 内容开始返回时调用 */
19   -- (void)webView:(CNLiveWebView *)webView didCommitWithURL:(NSURL *)url;
20   -/** 页面加载失败时调用 */
21   -- (void)webView:(CNLiveWebView *)webView didFinishLoadWithURL:(NSURL *)url;
22   -/** 页面加载完成之后调用 */
23   -- (void)webView:(CNLiveWebView *)webView didFailLoadWithError:(NSError *)error;
24   -@end
25   -
26   -@interface CNLiveWebView : UIView
27   -/** XWDelegate */
28   -@property (nonatomic, weak) id<CNLiveWebViewDelegate> delegate;
29   -/** 进度条颜色(默认蓝色) */
30   -@property (nonatomic, strong) UIColor *progressViewColor;
31   -/** 导航栏标题 */
32   -@property (nonatomic, copy) NSString *navigationItemTitle;
33   -/** 导航栏存在且有穿透效果(默认导航栏存在且有穿透效果) */
34   -@property (nonatomic, assign) BOOL isNavigationBarOrTranslucent;
35   -
36   -/** 类方法创建 XWWebView */
37   -+ (instancetype)webViewWithFrame:(CGRect)frame;
38   -/** 加载 web */
39   -- (void)loadRequest:(NSURLRequest *)request;
40   -/** 加载 HTML */
41   -- (void)loadHTMLString:(NSString *)HTMLString;
42   -/** 刷新数据 */
43   -- (void)reloadData;
44   -
45   -@end
CNLiveQrCodeModule/Classes/View/CNLiveWebView.m deleted 100755 → 0
1   -//
2   -// CNLiveWebView.m
3   -// CNLiveQrCodeModule
4   -//
5   -// Created by 153993236@qq.com on 11/12/2019.
6   -// Copyright (c) 2019 153993236@qq.com. All rights reserved.
7   -//
8   -
9   -#import "CNLiveWebView.h"
10   -#import <WebKit/WebKit.h>
11   -#import "QMUIKit.h"
12   -
13   -@interface CNLiveWebView () <WKNavigationDelegate, WKUIDelegate>
14   -// WKWebView
15   -@property (nonatomic, strong) WKWebView *wkWebView;
16   -// 进度条
17   -@property (nonatomic, strong) UIProgressView *progressView;
18   -
19   -@end
20   -
21   -@implementation CNLiveWebView
22   -
23   -static CGFloat const progressViewHeight = 2;
24   -
25   -- (instancetype)initWithFrame:(CGRect)frame {
26   - if (self = [super initWithFrame:frame]) {
27   - [self addSubview:self.wkWebView];
28   - [self addSubview:self.progressView];
29   - }
30   - return self;
31   -}
32   -
33   -+ (instancetype)webViewWithFrame:(CGRect)frame {
34   - return [[self alloc] initWithFrame:frame];
35   -}
36   -
37   -- (WKWebView *)wkWebView {
38   - if (!_wkWebView) {
39   - _wkWebView = [[WKWebView alloc] initWithFrame:self.bounds];
40   - _wkWebView.navigationDelegate = self;
41   - _wkWebView.UIDelegate = self;
42   - // KVO
43   - [self.wkWebView addObserver:self forKeyPath:NSStringFromSelector(@selector(estimatedProgress)) options:0 context:nil];
44   - }
45   - return _wkWebView;
46   -}
47   -
48   -- (UIProgressView *)progressView {
49   - if (!_progressView) {
50   - _progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];
51   - _progressView.trackTintColor = [UIColor clearColor];
52   - // 高度默认有导航栏且有穿透效果
53   - _progressView.frame = CGRectMake(0, NavigationContentTop, self.frame.size.width, progressViewHeight);
54   - // 设置进度条颜色
55   - _progressView.tintColor = [UIColor greenColor];
56   - }
57   - return _progressView;
58   -}
59   -
60   -- (void)setProgressViewColor:(UIColor *)progressViewColor {
61   - _progressViewColor = progressViewColor;
62   - if (progressViewColor) {
63   - _progressView.tintColor = progressViewColor;
64   - }
65   -}
66   -
67   -- (void)setIsNavigationBarOrTranslucent:(BOOL)isNavigationBarOrTranslucent {
68   - _isNavigationBarOrTranslucent = isNavigationBarOrTranslucent;
69   -
70   - if (isNavigationBarOrTranslucent == YES) { // 导航栏存在且有穿透效果
71   - _progressView.frame = CGRectMake(0, NavigationContentTop, self.frame.size.width, progressViewHeight);
72   - } else { // 导航栏不存在或者没有有穿透效果
73   - _progressView.frame = CGRectMake(0, 0, self.frame.size.width, progressViewHeight);
74   - }
75   -}
76   -
77   -// KVO
78   -- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
79   - if ([keyPath isEqualToString:NSStringFromSelector(@selector(estimatedProgress))] && object == self.wkWebView) {
80   - self.progressView.alpha = 1.0;
81   - BOOL animated = self.wkWebView.estimatedProgress > self.progressView.progress;
82   - [self.progressView setProgress:self.wkWebView.estimatedProgress animated:animated];
83   - if(self.wkWebView.estimatedProgress >= 0.97) {
84   - [UIView animateWithDuration:0.1 delay:0.3 options:UIViewAnimationOptionCurveEaseOut animations:^{
85   - self.progressView.alpha = 0.0;
86   - } completion:^(BOOL finished) {
87   - [self.progressView setProgress:0.0 animated:NO];
88   - }];
89   - }
90   - } else {
91   - [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
92   - }
93   -}
94   -
95   -#pragma mark - 加载的状态回调(WKNavigationDelegate)
96   -// 页面开始加载时调用
97   -- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation {
98   - if (self.delegate && [self.delegate respondsToSelector:@selector(webViewDidStartLoad:)]) {
99   - [self.delegate webViewDidStartLoad:self];
100   - }
101   -}
102   -// 当内容开始返回时调用
103   -- (void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation {
104   - if (self.delegate && [self.delegate respondsToSelector:@selector(webView:didCommitWithURL:)]) {
105   - [self.delegate webView:self didCommitWithURL:self.wkWebView.URL];
106   - }
107   - self.navigationItemTitle = self.wkWebView.title;
108   -}
109   -// 页面加载完成之后调用
110   -- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
111   - self.navigationItemTitle = self.wkWebView.title;
112   - if (self.delegate && [self.delegate respondsToSelector:@selector(webView:didFinishLoadWithURL:)]) {
113   - [self.delegate webView:self didFinishLoadWithURL:self.wkWebView.URL];
114   - }
115   - self.progressView.alpha = 0.0;
116   -}
117   -// 页面加载失败时调用
118   -- (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error {
119   - if (self.delegate && [self.delegate respondsToSelector:@selector(webView:didFailLoadWithError:)]) {
120   - [self.delegate webView:self didFailLoadWithError:error];
121   - }
122   - self.progressView.alpha = 0.0;
123   -}
124   -// 加载 web
125   -- (void)loadRequest:(NSURLRequest *)request {
126   - [self.wkWebView loadRequest:request];
127   -}
128   -// 加载 HTML
129   -- (void)loadHTMLString:(NSString *)HTMLString {
130   - [self.wkWebView loadHTMLString:HTMLString baseURL:nil];
131   -}
132   -// 刷新数据
133   -- (void)reloadData {
134   - [self.wkWebView reload];
135   -}
136   -// dealloc
137   -- (void)dealloc {
138   - [self.wkWebView removeObserver:self forKeyPath:NSStringFromSelector(@selector(estimatedProgress))];
139   -}
140   -
141   -
142   -@end
Example/CNLiveQrCodeModule.xcodeproj/project.pbxproj
... ... @@ -207,8 +207,8 @@
207 207 6003F586195388D20070C39A /* Sources */,
208 208 6003F587195388D20070C39A /* Frameworks */,
209 209 6003F588195388D20070C39A /* Resources */,
210   - 936400C36A68BB4DAA5C8A6E /* [CP] Embed Pods Frameworks */,
211   - 4644CC2D244368A8795F234F /* [CP] Copy Pods Resources */,
  210 + A6874231ED8CBF0F3DD0EA37 /* [CP] Embed Pods Frameworks */,
  211 + 03C7BF1E246C9ADAE9CFD775 /* [CP] Copy Pods Resources */,
212 212 );
213 213 buildRules = (
214 214 );
... ... @@ -299,44 +299,44 @@
299 299 /* End PBXResourcesBuildPhase section */
300 300  
301 301 /* Begin PBXShellScriptBuildPhase section */
302   - 331689B0771077B305836D8A /* [CP] Check Pods Manifest.lock */ = {
  302 + 03C7BF1E246C9ADAE9CFD775 /* [CP] Copy Pods Resources */ = {
303 303 isa = PBXShellScriptBuildPhase;
304 304 buildActionMask = 2147483647;
305 305 files = (
306 306 );
307   - inputFileListPaths = (
308   - );
309 307 inputPaths = (
310   - "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
311   - "${PODS_ROOT}/Manifest.lock",
312   - );
313   - name = "[CP] Check Pods Manifest.lock";
314   - outputFileListPaths = (
  308 + "${PODS_ROOT}/Target Support Files/Pods-CNLiveQrCodeModule_Example/Pods-CNLiveQrCodeModule_Example-resources.sh",
  309 + "${PODS_CONFIGURATION_BUILD_DIR}/CNLiveQrCodeModule/CNLiveQrCodeModule.bundle",
315 310 );
  311 + name = "[CP] Copy Pods Resources";
316 312 outputPaths = (
317   - "$(DERIVED_FILE_DIR)/Pods-CNLiveQrCodeModule_Example-checkManifestLockResult.txt",
  313 + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/CNLiveQrCodeModule.bundle",
318 314 );
319 315 runOnlyForDeploymentPostprocessing = 0;
320 316 shellPath = /bin/sh;
321   - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
  317 + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CNLiveQrCodeModule_Example/Pods-CNLiveQrCodeModule_Example-resources.sh\"\n";
322 318 showEnvVarsInLog = 0;
323 319 };
324   - 4644CC2D244368A8795F234F /* [CP] Copy Pods Resources */ = {
  320 + 331689B0771077B305836D8A /* [CP] Check Pods Manifest.lock */ = {
325 321 isa = PBXShellScriptBuildPhase;
326 322 buildActionMask = 2147483647;
327 323 files = (
328 324 );
  325 + inputFileListPaths = (
  326 + );
329 327 inputPaths = (
330   - "${PODS_ROOT}/Target Support Files/Pods-CNLiveQrCodeModule_Example/Pods-CNLiveQrCodeModule_Example-resources.sh",
331   - "${PODS_CONFIGURATION_BUILD_DIR}/CNLiveQrCodeModule/CNLiveQrCodeModule.bundle",
  328 + "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
  329 + "${PODS_ROOT}/Manifest.lock",
  330 + );
  331 + name = "[CP] Check Pods Manifest.lock";
  332 + outputFileListPaths = (
332 333 );
333   - name = "[CP] Copy Pods Resources";
334 334 outputPaths = (
335   - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/CNLiveQrCodeModule.bundle",
  335 + "$(DERIVED_FILE_DIR)/Pods-CNLiveQrCodeModule_Example-checkManifestLockResult.txt",
336 336 );
337 337 runOnlyForDeploymentPostprocessing = 0;
338 338 shellPath = /bin/sh;
339   - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CNLiveQrCodeModule_Example/Pods-CNLiveQrCodeModule_Example-resources.sh\"\n";
  339 + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
340 340 showEnvVarsInLog = 0;
341 341 };
342 342 667E6DC32E1A51CD56D1B74A /* [CP] Check Pods Manifest.lock */ = {
... ... @@ -361,7 +361,7 @@
361 361 shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
362 362 showEnvVarsInLog = 0;
363 363 };
364   - 936400C36A68BB4DAA5C8A6E /* [CP] Embed Pods Frameworks */ = {
  364 + A6874231ED8CBF0F3DD0EA37 /* [CP] Embed Pods Frameworks */ = {
365 365 isa = PBXShellScriptBuildPhase;
366 366 buildActionMask = 2147483647;
367 367 files = (
... ...