@@ -240,7 +240,6 @@ - (void)viewDidLoad {
240
240
#else
241
241
self.view .backgroundColor = [UIColor whiteColor ];
242
242
self.progressView .progressTintColor = self.navigationController .navigationBar .tintColor ;
243
- _backgroundLabel.textColor = [UIColor colorWithRed: 0.180 green: 0.192 blue: 0.196 alpha: 1.00 ];
244
243
#endif
245
244
}
246
245
@@ -584,7 +583,11 @@ - (_AXWebViewProgressView *)progressView {
584
583
- (UILabel *)backgroundLabel {
585
584
if (_backgroundLabel) return _backgroundLabel;
586
585
_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
587
589
_backgroundLabel.textColor = [UIColor colorWithRed: 0.322 green: 0.322 blue: 0.322 alpha: 1.00 ];
590
+ #endif
588
591
_backgroundLabel.font = [UIFont systemFontOfSize: 12 ];
589
592
_backgroundLabel.numberOfLines = 0 ;
590
593
_backgroundLabel.textAlignment = NSTextAlignmentCenter;
@@ -731,12 +734,12 @@ - (void)didStartLoad{
731
734
}
732
735
#if !AX_WEB_VIEW_CONTROLLER_USING_WEBKIT
733
736
_progressView.progress = 0.0 ;
737
+ _updating = [NSTimer scheduledTimerWithTimeInterval: 0.1 target: self selector: @selector (updatingProgress: ) userInfo: nil repeats: YES ];
734
738
#endif
735
739
if (_delegate && [_delegate respondsToSelector: @selector (webViewControllerDidStartLoad: )]) {
736
740
[_delegate webViewControllerDidStartLoad: self ];
737
741
}
738
742
_loading = YES ;
739
- // _updating = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(updatingProgress:) userInfo:nil repeats:YES];
740
743
}
741
744
#if AX_WEB_VIEW_CONTROLLER_USING_WEBKIT
742
745
- (void )didStartLoadWithNavigation : (WKNavigation *)navigation {
@@ -759,7 +762,9 @@ - (void)_didStartLoadWithObj:(id)object {
759
762
return ;
760
763
}
761
764
}
765
+ #if AX_WEB_VIEW_CONTROLLER_USING_WEBKIT
762
766
if ([object isKindOfClass: WKNavigationClass]) [self didStartLoadWithNavigation: object];
767
+ #endif
763
768
}
764
769
765
770
- (void )didFinishLoad {
@@ -1156,7 +1161,7 @@ - (void)webViewWebContentProcessDidTerminate:(WKWebView *)webView {
1156
1161
- (BOOL )webView : (UIWebView *)webView shouldStartLoadWithRequest : (NSURLRequest *)request navigationType : (UIWebViewNavigationType)navigationType {
1157
1162
// URL actions
1158
1163
if ([request.URL.absoluteString isEqualToString: kAX404NotFoundURLKey ] || [request.URL.absoluteString isEqualToString: kAXNetworkErrorURLKey ]) {
1159
- [self loadURL: _URL];
1164
+ [self loadURL: _URL]; return NO ;
1160
1165
}
1161
1166
// Resolve URL. Fixs the issue: https://github.com/devedbox/AXWebViewController/issues/7
1162
1167
NSURLComponents *components = [[NSURLComponents alloc ] initWithString: request.URL.absoluteString];
@@ -1170,7 +1175,7 @@ - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)
1170
1175
}
1171
1176
}
1172
1177
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.
1174
1179
if ([[UIApplication sharedApplication ] canOpenURL: request.URL]) {
1175
1180
if (UIDevice.currentDevice .systemVersion .floatValue >= 10.0 ) {
1176
1181
[UIApplication.sharedApplication openURL: request.URL options: @{} completionHandler: NULL ];
@@ -1224,6 +1229,9 @@ - (void)webViewDidFinishLoad:(UIWebView *)webView {
1224
1229
}
1225
1230
1226
1231
- (void )webView : (UIWebView *)webView didFailLoadWithError : (NSError *)error {
1232
+ if (error.code == NSURLErrorCancelled) {
1233
+ [webView reload ]; return ;
1234
+ }
1227
1235
[self didFailLoadWithError: error];
1228
1236
}
1229
1237
#endif
@@ -1370,7 +1378,7 @@ -(void)endPopSnapShotView{
1370
1378
}];
1371
1379
}
1372
1380
}
1373
- # endif
1381
+
1374
1382
- (void )updatingProgress : (NSTimer *)sender {
1375
1383
if (!_loading) {
1376
1384
if (_progressView.progress >= 1.0 ) {
@@ -1387,6 +1395,7 @@ - (void)updatingProgress:(NSTimer *)sender {
1387
1395
}
1388
1396
}
1389
1397
}
1398
+ #endif
1390
1399
1391
1400
- (void )setupSubviews {
1392
1401
// Add from label and constraints.
@@ -1564,6 +1573,7 @@ - (void)orientationChanged:(NSNotification *)note {
1564
1573
}
1565
1574
@end
1566
1575
1576
+ #if AX_WEB_VIEW_CONTROLLER_USING_WEBKIT
1567
1577
@implementation AXWebViewController (Security)
1568
1578
- (WKWebViewDidReceiveAuthenticationChallengeHandler)challengeHandler {
1569
1579
return _challengeHandler;
@@ -1581,6 +1591,7 @@ - (void)setSecurityPolicy:(AFSecurityPolicy *)securityPolicy {
1581
1591
_securityPolicy = securityPolicy;
1582
1592
}
1583
1593
@end
1594
+ #endif
1584
1595
1585
1596
#if AX_WEB_VIEW_CONTROLLER_USING_WEBKIT
1586
1597
@implementation UIProgressView (WebKit)
0 commit comments