Jag*_*een 7 xcode uiwebview xcode5 xcode6 ios8
我有工作项目,我在UIWebView中显示pdf文件在使用XCode5
在iOS8beta5中测试我的应用程序时,它无法正常工作
在日志中显示failed to find PDF header : '%PDF' not found
self.myWebView.delegate = self;
NSString *path = [[NSBundle mainBundle] pathForResource:@"201" ofType:@"pdf"];
NSURL *targetURL = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[self.myWebView loadRequest:request];
Run Code Online (Sandbox Code Playgroud)
Quicklook framework may did not display PDF file in some application
但他们没有提到任何关于UIWebView,
Jag*_*een 11
我找到了一种在WebView中查看PDF的解决方法
// Create pdf path & url
NSString *path = [[NSBundle mainBundle] pathForResource:@"201" ofType:@"pdf"];
NSURL *targetURL = [NSURL fileURLWithPath:path];
// Load pdf in WebView
NSData *pdfData = [[NSData alloc] initWithContentsOfURL:targetURL];
[self.webView loadData:pdfData MIMEType:@"application/pdf" textEncodingName:@"utf-8" baseURL:nil];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5792 次 |
| 最近记录: |