webview查看PDF

// view pdf 文件
- (void)viewPDF:(NSString *)filePath {
    self.webView.frame = self.frame;
    NSURL *url = [NSURL fileURLWithPath:filePath];
    [self.webView loadRequest:[NSURLRequest requestWithURL:url]];
}
// view pdf data
- (void)viewPDFWithData:(NSData *)data {
    self.webView.frame = self.frame;
    [self.webView loadData:data MIMEType:@"application/pdf" textEncodingName:@"UTF-8" baseURL:[NSURL URLWithString:@"http://"]];
}

你可能感兴趣的:(webview查看PDF)