1

I'm working with a UIDocumentInteractionController in iOS 7 to preview a PDF which is installed as part of the app bundle. Everything works great when I load the file using;

NSURL *url = [[NSBundle mainBundle] URLForResource:pdfName withExtension:@"pdf"];
self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:url];
self.documentInteractionController.delegate = self;
[self.documentInteractionController presentPreviewAnimated:YES];

As expected the PDF loads absolutely fine and a preview controller appears showing the document. As soon as I put the device into Guided Access mode and then try to open the PDF the controller appears as expected but the PDF does not appear, instead the controller shows the file name, format and size.

Debugging in Xcode I see the following message in the log;

Failed to load quicklookd with error : The operation couldn’t be completed. (_UIViewServiceInterfaceErrorDomain error 0.)

As a sanity check I tried using a QLPreviewController as well but this has yielded exactly the same result.

Does anyone have any pointers on this? Trawling through the documentation I haven't been able to turn up much yet.

marcus.ramsden
  • 2,633
  • 1
  • 22
  • 33
  • Looks like an Apple bug. Have you tried with the iOS7.1 beta 5 SDK? Perhaps it has been fixed there. Is this on a device or simulator? Try on device. If it still fails, you should open a bug report with Apple and post the radar number so people can duplicate. – Léo Natan Mar 06 '14 at 23:43
  • Just grabbing the beta at the moment to give it a shot on a device. – marcus.ramsden Mar 06 '14 at 23:45
  • Remember not to install on a production device. It is still a beta. For example, in iOS7.1, Apple has not yet fixed the SSL bug. – Léo Natan Mar 06 '14 at 23:46
  • Did you figure this out? We just encountered this problem as well. – Christian A. Strømmen Mar 17 '14 at 11:34
  • I filed a bug with Apple. I'll let everyone know. Works OK on iOS 6 but not 7.1. We are either opening a web browser now or converting to an image gallery instead. – malaki1974 Apr 22 '14 at 20:28

1 Answers1

0

This seems to be a genuine Apple bug. The best workaround I've found is to use a UIWebView instead:

NSURLRequest *urlRequest = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:pdfPath]];
[self.webView loadRequest:urlRequest];

Obviously if you want to present it as a modal you'll have to do some more leg work...

Workshed
  • 236
  • 1
  • 8