// // ShowPDFWebViewController.m // redstar // // Created by admin on 16/1/14. // Copyright © 2016年 ZWF. All rights reserved. // #import "ShowPDFWebViewController.h" #import <MBProgressHUD.h> @interface ShowPDFWebViewController () @property (nonatomic, strong) UIWebView *webView; @end @implementation ShowPDFWebViewController - (void)viewDidLoad { [super viewDidLoad]; [self setupNav]; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:self.url]]; [self.webView loadRequest:request]; } - (void)setupNav { UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 30)]; [customLab setTextColor:[UIColor whiteColor]]; [customLab setText:self.fileName]; customLab.font = [UIFont boldSystemFontOfSize:19]; self.navigationItem.titleView = customLab; UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom]; backBtn.frame = CGRectMake(0, 0, 30, 44); [backBtn setImage:[UIImage imageNamed:@"back_btn"] forState:UIControlStateNormal]; [backBtn addTarget:self action:@selector(doBack:) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn]; self.navigationItem.leftBarButtonItem = backItem; } - (void)doBack:(UIBarButtonItem *)sender { [self.navigationController popViewControllerAnimated:YES]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (UIWebView *)webView { if (!_webView) { _webView = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].bounds]; _webView.translatesAutoresizingMaskIntoConstraints = NO; [self.view addSubview:_webView]; NSLayoutConstraint *tableTop = [NSLayoutConstraint constraintWithItem:_webView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:0]; [self.view addConstraint:tableTop]; NSLayoutConstraint *tableLeft = [NSLayoutConstraint constraintWithItem:_webView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0]; [self.view addConstraint:tableLeft]; NSLayoutConstraint *tableRight = [NSLayoutConstraint constraintWithItem:_webView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1.0 constant:0]; [self.view addConstraint:tableRight]; NSLayoutConstraint *tableBottom = [NSLayoutConstraint constraintWithItem:_webView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0]; [self.view addConstraint:tableBottom]; } return _webView; } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end