Skip to content

Commit e9f9dd2

Browse files
committed
Updated UIWebView.
1 parent 0cd94ba commit e9f9dd2

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

.DS_Store

0 Bytes
Binary file not shown.

AXWebViewController/AXWebViewController/AXWebViewController.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
#endif
3232

3333
#ifndef AX_WEB_VIEW_CONTROLLER_USING_WEBKIT
34-
#define AX_WEB_VIEW_CONTROLLER_USING_WEBKIT __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_8_0
34+
// #define AX_WEB_VIEW_CONTROLLER_USING_WEBKIT __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_8_0
35+
#define AX_WEB_VIEW_CONTROLLER_USING_WEBKIT 0
3536
#endif
3637

3738
#ifndef AX_WEB_VIEW_CONTROLLER_DEFINES_PROXY

AXWebViewController/AXWebViewController/AXWebViewController.m

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ - (void)viewDidLoad {
240240
#else
241241
self.view.backgroundColor = [UIColor whiteColor];
242242
self.progressView.progressTintColor = self.navigationController.navigationBar.tintColor;
243-
_backgroundLabel.textColor = [UIColor colorWithRed:0.180 green:0.192 blue:0.196 alpha:1.00];
244243
#endif
245244
}
246245

@@ -584,7 +583,11 @@ - (_AXWebViewProgressView *)progressView {
584583
- (UILabel *)backgroundLabel {
585584
if (_backgroundLabel) return _backgroundLabel;
586585
_backgroundLabel = [[UILabel alloc] initWithFrame:CGRectZero];
586+
#if AX_WEB_VIEW_CONTROLLER_USING_WEBKIT
587+
_backgroundLabel.textColor = [UIColor colorWithRed:0.180 green:0.192 blue:0.196 alpha:1.00];
588+
#else
587589
_backgroundLabel.textColor = [UIColor colorWithRed:0.322 green:0.322 blue:0.322 alpha:1.00];
590+
#endif
588591
_backgroundLabel.font = [UIFont systemFontOfSize:12];
589592
_backgroundLabel.numberOfLines = 0;
590593
_backgroundLabel.textAlignment = NSTextAlignmentCenter;
@@ -731,12 +734,12 @@ - (void)didStartLoad{
731734
}
732735
#if !AX_WEB_VIEW_CONTROLLER_USING_WEBKIT
733736
_progressView.progress = 0.0;
737+
_updating = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(updatingProgress:) userInfo:nil repeats:YES];
734738
#endif
735739
if (_delegate && [_delegate respondsToSelector:@selector(webViewControllerDidStartLoad:)]) {
736740
[_delegate webViewControllerDidStartLoad:self];
737741
}
738742
_loading = YES;
739-
// _updating = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(updatingProgress:) userInfo:nil repeats:YES];
740743
}
741744
#if AX_WEB_VIEW_CONTROLLER_USING_WEBKIT
742745
- (void)didStartLoadWithNavigation:(WKNavigation *)navigation {
@@ -759,7 +762,9 @@ - (void)_didStartLoadWithObj:(id)object {
759762
return;
760763
}
761764
}
765+
#if AX_WEB_VIEW_CONTROLLER_USING_WEBKIT
762766
if ([object isKindOfClass:WKNavigationClass]) [self didStartLoadWithNavigation:object];
767+
#endif
763768
}
764769

765770
- (void)didFinishLoad{
@@ -1156,7 +1161,7 @@ - (void)webViewWebContentProcessDidTerminate:(WKWebView *)webView {
11561161
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
11571162
// URL actions
11581163
if ([request.URL.absoluteString isEqualToString:kAX404NotFoundURLKey] || [request.URL.absoluteString isEqualToString:kAXNetworkErrorURLKey]) {
1159-
[self loadURL:_URL];
1164+
[self loadURL:_URL]; return NO;
11601165
}
11611166
// Resolve URL. Fixs the issue: https://github.com/devedbox/AXWebViewController/issues/7
11621167
NSURLComponents *components = [[NSURLComponents alloc] initWithString:request.URL.absoluteString];
@@ -1170,7 +1175,7 @@ - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)
11701175
}
11711176
}
11721177
return NO;
1173-
} else if (![[NSPredicate predicateWithFormat:@"SELF MATCHES[cd] 'https' OR SELF MATCHES[cd] 'http'"] evaluateWithObject:components.scheme]) {// For any other schema.
1178+
} else if (![[NSPredicate predicateWithFormat:@"SELF MATCHES[cd] 'https' OR SELF MATCHES[cd] 'http' OR SELF MATCHES[cd] 'file' OR SELF MATCHES[cd] 'about'"] evaluateWithObject:components.scheme]) {// For any other schema.
11741179
if ([[UIApplication sharedApplication] canOpenURL:request.URL]) {
11751180
if (UIDevice.currentDevice.systemVersion.floatValue >= 10.0) {
11761181
[UIApplication.sharedApplication openURL:request.URL options:@{} completionHandler:NULL];
@@ -1224,6 +1229,9 @@ - (void)webViewDidFinishLoad:(UIWebView *)webView {
12241229
}
12251230

12261231
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
1232+
if (error.code == NSURLErrorCancelled) {
1233+
[webView reload]; return;
1234+
}
12271235
[self didFailLoadWithError:error];
12281236
}
12291237
#endif
@@ -1370,7 +1378,7 @@ -(void)endPopSnapShotView{
13701378
}];
13711379
}
13721380
}
1373-
#endif
1381+
13741382
- (void)updatingProgress:(NSTimer *)sender {
13751383
if (!_loading) {
13761384
if (_progressView.progress >= 1.0) {
@@ -1387,6 +1395,7 @@ - (void)updatingProgress:(NSTimer *)sender {
13871395
}
13881396
}
13891397
}
1398+
#endif
13901399

13911400
- (void)setupSubviews {
13921401
// Add from label and constraints.
@@ -1564,6 +1573,7 @@ - (void)orientationChanged:(NSNotification *)note {
15641573
}
15651574
@end
15661575

1576+
#if AX_WEB_VIEW_CONTROLLER_USING_WEBKIT
15671577
@implementation AXWebViewController (Security)
15681578
- (WKWebViewDidReceiveAuthenticationChallengeHandler)challengeHandler {
15691579
return _challengeHandler;
@@ -1581,6 +1591,7 @@ - (void)setSecurityPolicy:(AFSecurityPolicy *)securityPolicy {
15811591
_securityPolicy = securityPolicy;
15821592
}
15831593
@end
1594+
#endif
15841595

15851596
#if AX_WEB_VIEW_CONTROLLER_USING_WEBKIT
15861597
@implementation UIProgressView (WebKit)

0 commit comments

Comments
 (0)