Commit 9fb303a4c0f9efc605d36cc94571049815c2119d
1 parent
87bc2366
提交0.0.26_更改网页加载
Showing
2 changed files
with
35 additions
and
5 deletions
CNLiveServiceCenterModule.podspec
| @@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
| 8 | 8 | ||
| 9 | Pod::Spec.new do |s| | 9 | Pod::Spec.new do |s| |
| 10 | s.name = 'CNLiveServiceCenterModule' | 10 | s.name = 'CNLiveServiceCenterModule' |
| 11 | - s.version = '0.0.25' | 11 | + s.version = '0.0.26' |
| 12 | s.summary = '网家家企业端服务中心模块' | 12 | s.summary = '网家家企业端服务中心模块' |
| 13 | 13 | ||
| 14 | # This description is used to generate tags and improve search results. | 14 | # This description is used to generate tags and improve search results. |
CNLiveServiceCenterModule/Classes/CNLiveServiceCenterModule/Controller/CNLiveBCreatorViewController.m
| @@ -32,6 +32,15 @@ | @@ -32,6 +32,15 @@ | ||
| 32 | @implementation CNLiveBCreatorViewController | 32 | @implementation CNLiveBCreatorViewController |
| 33 | 33 | ||
| 34 | 34 | ||
| 35 | +- (void)dealloc | ||
| 36 | +{ | ||
| 37 | + if (self.wkwebView && self) { | ||
| 38 | + [self.wkwebView removeObserver:self forKeyPath:@"estimatedProgress"]; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + | ||
| 42 | +} | ||
| 43 | + | ||
| 35 | - (void)viewDidLoad { | 44 | - (void)viewDidLoad { |
| 36 | [super viewDidLoad]; | 45 | [super viewDidLoad]; |
| 37 | [self.view setBackgroundColor:[UIColor whiteColor]]; | 46 | [self.view setBackgroundColor:[UIColor whiteColor]]; |
| @@ -65,6 +74,8 @@ | @@ -65,6 +74,8 @@ | ||
| 65 | 74 | ||
| 66 | self.view.backgroundColor = [UIColor whiteColor]; | 75 | self.view.backgroundColor = [UIColor whiteColor]; |
| 67 | WKWebView *webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, kNavigationBarHeight, kScreenWidth, KScreenHeight - kNavigationBarHeight)]; | 76 | WKWebView *webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, kNavigationBarHeight, kScreenWidth, KScreenHeight - kNavigationBarHeight)]; |
| 77 | + webView.navigationDelegate = self; | ||
| 78 | + webView.UIDelegate = self; | ||
| 68 | [self.view addSubview:webView]; | 79 | [self.view addSubview:webView]; |
| 69 | webView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; | 80 | webView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; |
| 70 | [webView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:nil]; | 81 | [webView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:nil]; |
| @@ -94,11 +105,16 @@ | @@ -94,11 +105,16 @@ | ||
| 94 | if ([keyPath isEqualToString:@"estimatedProgress"]) { | 105 | if ([keyPath isEqualToString:@"estimatedProgress"]) { |
| 95 | CGFloat newProgress = [[change objectForKey:NSKeyValueChangeNewKey] doubleValue]; | 106 | CGFloat newProgress = [[change objectForKey:NSKeyValueChangeNewKey] doubleValue]; |
| 96 | if (newProgress == 1) { | 107 | if (newProgress == 1) { |
| 97 | - self.progressView.hidden = YES; | ||
| 98 | - [self.progressView setProgress:0 animated:NO]; | 108 | + if (self) { |
| 109 | + self.progressView.hidden = YES; | ||
| 110 | + [self.progressView setProgress:0 animated:NO]; | ||
| 111 | + } | ||
| 112 | + | ||
| 99 | }else{ | 113 | }else{ |
| 100 | - self.progressView.hidden = NO; | ||
| 101 | - [self.progressView setProgress:newProgress animated:YES]; | 114 | + if (self) { |
| 115 | + self.progressView.hidden = NO; | ||
| 116 | + [self.progressView setProgress:newProgress animated:YES]; | ||
| 117 | + } | ||
| 102 | } | 118 | } |
| 103 | } | 119 | } |
| 104 | } | 120 | } |
| @@ -110,6 +126,20 @@ | @@ -110,6 +126,20 @@ | ||
| 110 | 126 | ||
| 111 | } | 127 | } |
| 112 | 128 | ||
| 129 | + // 页面开始加载时调用 | ||
| 130 | +- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation { | ||
| 131 | +} | ||
| 132 | + // 页面加载失败时调用 | ||
| 133 | +- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error { | ||
| 134 | + if (self) { | ||
| 135 | + [self.progressView setProgress:0.0f animated:NO]; | ||
| 136 | + [QMUITips showError:@"加载失败,请检查网络" inView:self.view hideAfterDelay:0.5]; | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + | ||
| 140 | + | ||
| 141 | +} | ||
| 142 | + | ||
| 113 | - (void)backAction:(UIBarButtonItem *)item { | 143 | - (void)backAction:(UIBarButtonItem *)item { |
| 114 | 144 | ||
| 115 | NSLog(@"输出内容"); | 145 | NSLog(@"输出内容"); |