PDFViewController.m 1.56 KB
Newer Older
勾芒's avatar
勾芒 committed
1 2 3 4 5 6 7 8 9
//
//  PDFViewController.m
//  Lighting
//
//  Created by 曹云霄 on 16/5/17.
//  Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//

#import "PDFViewController.h"
10 11
#import <WebKit/WebKit.h>
@interface PDFViewController ()<WKNavigationDelegate>
勾芒's avatar
勾芒 committed
12

13
@property (nonatomic,strong) WKWebView *webView;
勾芒's avatar
勾芒 committed
14 15 16 17 18 19 20 21 22 23 24 25

@end

@implementation PDFViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    [self uiConfigAction];
}

勾芒's avatar
勾芒 committed
26

勾芒's avatar
勾芒 committed
27
#pragma mark -UI
勾芒's avatar
勾芒 committed
28
- (void)uiConfigAction
勾芒's avatar
勾芒 committed
29
{
30
    self.webView = [[WKWebView alloc] initWithFrame:self.view.bounds];
勾芒's avatar
勾芒 committed
31
    [self.view addSubview:self.webView];
32
    self.webView.navigationDelegate = self;
勾芒's avatar
勾芒 committed
33 34
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:_pdfURLString]];
    [self.webView loadRequest:request];
勾芒's avatar
勾芒 committed
35
    [self.view addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(PDFClickAction)]];
勾芒's avatar
勾芒 committed
36
}
勾芒's avatar
勾芒 committed
37 38


勾芒's avatar
勾芒 committed
39 40
#pragma mark -dismiss
- (void)PDFClickAction
勾芒's avatar
勾芒 committed
41 42 43
{
    [self dismissViewControllerAnimated:YES completion:nil];
}
勾芒's avatar
勾芒 committed
44

45
- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(null_unspecified WKNavigation *)navigation
勾芒's avatar
勾芒 committed
46 47 48
{
    [self CreateMBProgressHUDLoding];
}
49 50

- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
勾芒's avatar
勾芒 committed
51 52 53
{
    [self RemoveMBProgressHUDLoding];
}
勾芒's avatar
勾芒 committed
54

勾芒's avatar
勾芒 committed
55

56 57 58 59 60
- (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error
{
    [self ErrorMBProgressView:@"加载失败"];
    [self dismissViewControllerAnimated:YES completion:nil];
}
勾芒's avatar
勾芒 committed
61 62 63 64




勾芒's avatar
勾芒 committed
65
@end