// // MyWebViewVC.m // jiaPei // // Created by EchoShacolee on 2018/9/5. // Copyright © 2018年 JCZ. All rights reserved. // #import "MyWebViewVC.h" #import @interface MyWebViewVC () @property(nonatomic,strong)WKWebView *webView; @end @implementation MyWebViewVC - (void)viewDidLoad { [super viewDidLoad]; [self.view addSubview:self.webView]; //返回按钮 UIImage *backImg = [[UIImage imageNamed:@"scanBack"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithImage:backImg style:UIBarButtonItemStylePlain target:self action:@selector(goBack)]; self.navigationItem.leftBarButtonItem = leftItem; //开始加载 if (!_urlString || _urlString.length == 0) { return; } if (![Util connectedToNetWork]) { showMsgUnconnect(); return; } [MBProgressHUD showLoadToView:self.view]; NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:_urlString]]; [self.webView loadRequest:request]; } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; self.tabBarController.tabBar.hidden = YES; } -(void)goBack { [self.navigationController popViewControllerAnimated:YES]; } -(WKWebView *)webView{ if (!_webView) { WKWebView *view = [[WKWebView alloc] initWithFrame:kFrame]; view.navigationDelegate = self; _webView = view; } return _webView; } #pragma mark - // 页面加载失败时调用 - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error{ [MBProgressHUD hideHUDForView:self.view]; } // 页面加载完毕时调用 - (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation{ [MBProgressHUD hideHUDForView:self.view]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end