无法在iOS8beta5中使用UIWebView打开PDF文件

Jag*_*een 7 xcode uiwebview xcode5 xcode6 ios8

我有工作项目,我在UIWebView中显示pdf文件在使用XCode5
iOS8beta5中测试我的应用程序时,它无法正常工作
日志中显示failed to find PDF header : '%PDF' not found


我使用下面的代码创建示例应用程序,它也有同样的问题
CODE:

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)


我读了发行说明,Apple写道, Quicklook framework may did not display PDF file in some application 但他们没有提到任何关于UIWebView, 在此输入图像描述

参考


注意:
iOS8beta4中没有出现此问题.
在XCode6 + iOS8beta5中也会出现同样的问题.
我也检查不同的PDF文件,但有同样的问题.
问题:
1]有没有人为上述问题做过修复?
如果是,请提供一些示例代码.

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)