123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- //
- // TRDetailVC.m
- // jiaPei
- //
- // Created by apple on 15/12/24.
- // Copyright © 2015年 JCZ. All rights reserved.
- //
- #import "TRDetailVC.h"
- #import <WebKit/WebKit.h>
- @interface TRDetailVC ()<WKNavigationDelegate>
- @end
- @implementation TRDetailVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self myInit];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- -(void)myInit
- {
- [self configNavigationBar];
- [self.view setBackgroundColor:[UIColor whiteColor]];
- if (_file.length >9 ) {
- [self setTitle:[[_file substringToIndex:9] stringByAppendingString:@"..."]];
- }else{
- [self setTitle:_file];
- }
- WKWebView* webView=[[WKWebView alloc]initWithFrame:kFrame];
- webView.height = kSize.height-kNavOffSet;
- webView.navigationDelegate = self;
- [self.view addSubview:webView];
-
- NSString *htmlPath;
- NSURL *url;
- htmlPath = [[NSBundle mainBundle] pathForResource:_file ofType:@"html"];
- if (htmlPath && ![htmlPath isEqualToString:@""]) {
- url = [NSURL fileURLWithPath:htmlPath isDirectory:NO];
- [MBProgressHUD showLoadToView:self.view];
- [webView loadRequest:[NSURLRequest requestWithURL:url]];
- }else{
- ShowMsg(@"未找到该页面");
- }
- }
- #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
|