QLPreviewController not working in iOS 6

benr75 picture benr75 · Sep 28, 2012 · Viewed 8.7k times · Source

In iOS 6 the QLPreviewController no longer loads a PDF from a URL. It works fine in iOS 5. I have implemented the QLPreviewControllerDataSource methods as documented here.

#pragma mark - QLPreviewControllerDataSource
- (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)controller {
    return 1;
}

- (id <QLPreviewItem>) previewController: (QLPreviewController *) controller previewItemAtIndex: (NSInteger) index;
{
    NSURL *fileURL = [NSURL URLWithString:@"http://www.bliley.net/XTAL/PDF_Instructions/Test_File.pdf"];
    return fileURL;
}

This works perfectly in iOS 5, however in iOS 6 the console outputs:

Couldn't issue file extension for path: /XTAL/PDF_Instructions/Test_File.pdf

Answer

valheru picture valheru · Oct 8, 2012

Have you tried using fileURLWithPath instead of URLWithString? I had other issues that were fixed by doing so.

Also not sure if QLPreviewController will handle remote URLs. If not, you could download the file and then display it.