123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- //
- // TrafficRulesViewController.m
- // Miaxis
- //
- // Created by tongjun on 14-1-20.
- // Copyright (c) 2014年 tongjun. All rights reserved.
- //
- #import "TrafficRulesViewController.h"
- #import <WebKit/WebKit.h>
- @interface TrafficRulesViewController ()<WKNavigationDelegate>
- {
- 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
|