Question

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.

Was it helpful?

Solution

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...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top