failed to find PDF header: `%PDF' not found
I agree, there seems to be a bug (or change of behaviour) in iOS 8 beta 5 which means that your code does not work anymore (and it was valid. I have the same and it worked fine up to iOS 8 beta 4).
I think there is a problem with type detection because if I do the following, it works:
NSLog(@"About to request PDF document loading...");NSData *pdfData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:urlStr]];[self.webView loadData:pdfData MIMEType:@"application/pdf" textEncodingName:@"utf-8" baseURL:nil];
Now that bit of code should not be used "as is" as it is synchronous.
I feel Nithin's answer was valid but it does not answer the problem specifically seen with iOS 8 beta 5. The main code is the same and will hit the same iOS bug.
This worked for me 👊👍
NSURL *targetURL = [NSURL fileURLWithPath:pdfFilePath]; // <pdfFilePath> if full path of your pdf fileNSData *pdfData = [[NSData alloc] initWithContentsOfURL:targetURL];[self.webview loadData:pdfData MIMEType:@"application/pdf" textEncodingName:@"utf-8" baseURL:nil];
Update on SEP 9 2014: iOS8 GM fixed this issue for apps I'm working with.
Response prior to SEP 9 2014It is reported as a known bug by Apple in iOS8 Beta 5 release notes.https://developer.apple.com/library/prerelease/ios/releasenotes/General/RN-iOSSDK-8.0/https://devforums.apple.com/message/1017919#1017919
We should wait next release and see if it is fixed.