// // TrafficRulesViewController.m // Miaxis // // Created by tongjun on 14-1-20. // Copyright (c) 2014年 tongjun. All rights reserved. // #import "TrafficRulesViewController.h" #import @interface TrafficRulesViewController () { WKWebView* webView; } @end @implementation TrafficRulesViewController -(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; self.navigationController.navigationBarHidden = NO; } - (void)viewDidLoad { [super viewDidLoad]; [self.view setBackgroundColor:[UIColor whiteColor]]; NSArray *urls=[myDelegate.url componentsSeparatedByString:@";"]; [self setTitle:[urls objectAtIndex:0]]; if ([urls[0] isEqualToString:@"帮助"]) { [self configNavigationBar]; }else{ [self configNavigationBar]; } webView=[[WKWebView alloc]initWithFrame:kFrame]; webView.height = kSize.height-kNavOffSet; webView.backgroundColor = [UIColor clearColor]; webView.navigationDelegate = self; [self.view addSubview:webView]; [self loadHtml]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } #pragma mark - -(void)loadHtml { NSArray *urls=[myDelegate.url componentsSeparatedByString:@";"]; NSString *htmlPath; NSURL *url; //NSLog(@"web----html----%@",urls); if (urls.count > 2) { htmlPath = urls[1]; url = [NSURL URLWithString:htmlPath]; if (![Util connectedToNetWork]) { showMsgUnconnect(); return; } }else{ htmlPath = [[NSBundle mainBundle] pathForResource:[urls objectAtIndex:1] ofType:@"html"]; url = [NSURL fileURLWithPath:htmlPath isDirectory:NO]; } [MBProgressHUD showLoadToView:self.view]; [webView loadRequest:[NSURLRequest requestWithURL:url]]; } #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]; } @end