|
@@ -9,12 +9,12 @@
|
|
|
#import "JYNewWebController.h"
|
|
|
#import <WebKit/WebKit.h>
|
|
|
|
|
|
-@interface JYNewWebController ()
|
|
|
+@interface JYNewWebController ()<WKNavigationDelegate,UIWebViewDelegate>
|
|
|
|
|
|
|
|
|
@property (nonatomic, strong) UIProgressView *progressView;
|
|
|
-@property (nonatomic, strong) WKWebView *webView;
|
|
|
-
|
|
|
+//@property (nonatomic, strong) WKWebView *webView;
|
|
|
+@property (nonatomic, strong) UIWebView *webView;
|
|
|
@end
|
|
|
|
|
|
@implementation JYNewWebController
|
|
@@ -103,13 +103,17 @@
|
|
|
backBtn_1.hidden = NO;
|
|
|
}
|
|
|
|
|
|
- self.webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, H, WIDTH, HEIGHT-TAB_BAR_HEIGHT)];
|
|
|
+ self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, H, WIDTH, HEIGHT-STATUS_BAR_HEIGHT-H)];
|
|
|
if (iPhoneX) {
|
|
|
if (@available(iOS 11.0, *)) {
|
|
|
self.webView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
|
|
}
|
|
|
}
|
|
|
self.webView.scrollView.bounces = NO;
|
|
|
+ _webView.scrollView.bounces = NO;
|
|
|
+
|
|
|
+ _webView.delegate = self;
|
|
|
+ _webView.userInteractionEnabled = YES;
|
|
|
[self.webView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:nil];
|
|
|
[self.view addSubview:self.webView];
|
|
|
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.url]]];
|
|
@@ -122,13 +126,80 @@
|
|
|
// Do any additional setup after loading the view.
|
|
|
|
|
|
self.view.backgroundColor = [UIColor whiteColor];
|
|
|
- NSLog(@"title:%@",self.title);
|
|
|
+ NSLog(@"title:%@",self.titleShow);
|
|
|
+ NSLog(@"url:%@",self.url);
|
|
|
[self initUI];//渲染页面
|
|
|
[self.view addSubview:self.progressView];
|
|
|
-
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dismissSelf) name:@"kNewWebControllerDismiss" object:nil];
|
|
|
}
|
|
|
|
|
|
+#pragma mark - UIWebViewDelegate
|
|
|
+- (void)webViewDidStartLoad:(UIWebView *)webView {
|
|
|
+ [[LXViewControllerManager shareViewControllerManager] showHudText:@""];
|
|
|
+}
|
|
|
+- (void)webViewDidFinishLoad:(UIWebView *)webView{
|
|
|
+ [[LXViewControllerManager shareViewControllerManager] hideHud];
|
|
|
+ [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitUserSelect='none';"];
|
|
|
+ // Disable callout
|
|
|
+ [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitTouchCallout='none';"];
|
|
|
+}
|
|
|
+
|
|
|
+-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
|
|
|
+ [[LXViewControllerManager shareViewControllerManager] hideHud];
|
|
|
+ [[GlobalData shareInstance] addOnePlistData:@{
|
|
|
+ @"detail":[[self.webView stringByEvaluatingJavaScriptFromString:@"document.location.href"] stringByAppendingString:[NSString stringWithFormat:@"\n%@",[error description]]],
|
|
|
+ @"reqTime":[NSNumber numberWithInt:0],
|
|
|
+ }];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+#pragma mark - WKNavigationDelegate
|
|
|
+/* 页面加载完成 */
|
|
|
+//- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{
|
|
|
+//
|
|
|
+// [self.webView evaluateJavaScript:@"document.documentElement.style.webkitTouchCallout='none';" completionHandler:nil];
|
|
|
+// [self.webView evaluateJavaScript:@"document.documentElement.style.webkitUserSelect='none';"completionHandler:nil];
|
|
|
+//}
|
|
|
+//// 页面开始加载时调用
|
|
|
+//- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation{
|
|
|
+//
|
|
|
+//}
|
|
|
+//// 当内容开始返回时调用
|
|
|
+//- (void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation{
|
|
|
+//}
|
|
|
+//
|
|
|
+//// 页面加载失败时调用
|
|
|
+//- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(nonnull NSError *)error{
|
|
|
+// [[GlobalData shareInstance] addOnePlistData:@{
|
|
|
+// @"detail":[[self stringByEvaluatingJavaScriptFromString:@"document.location.href"] stringByAppendingString:[NSString stringWithFormat:@"\n%@",[error description]]],
|
|
|
+// @"reqTime":[NSNumber numberWithInt:0],
|
|
|
+// }];
|
|
|
+//}
|
|
|
+//- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script
|
|
|
+//{
|
|
|
+// __block NSString *resultString = nil;
|
|
|
+// __block BOOL finished = NO;
|
|
|
+//
|
|
|
+// [self.webView evaluateJavaScript:script completionHandler:^(id result, NSError *error) {
|
|
|
+// if (error == nil) {
|
|
|
+// if (result != nil) {
|
|
|
+// resultString = [NSString stringWithFormat:@"%@", result];
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// NSLog(@"evaluateJavaScript error : %@", error.localizedDescription);
|
|
|
+// }
|
|
|
+// finished = YES;
|
|
|
+// }];
|
|
|
+//
|
|
|
+// while (!finished) {
|
|
|
+// [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
|
|
|
+// }
|
|
|
+// return resultString;
|
|
|
+//}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
-(void)backBtn1Click
|
|
|
{
|
|
|
if (self.webView.canGoBack) {// web能退 就后退
|