objective-ciosios6quicklookqlpreviewcontroller

iOS 6.0 Quicklook QLPreviewController errors with: "Cannot find preview item for loaded proxy"


My application has been using the QLPreviewController to display files of all types and in iOS 5.x , it seemed to do so just fine.

Now, in iOS 6.0, I get an error and it shows the controller but with a constant loading indicator and never actually loads anything.

The error in the log is: Cannot find preview item for loaded proxy: <QLPreviewItemProxy: 0x8dbf480> - file://localhost/Users/me/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/E6A58F8D-71F3-4C7A-B16E-4BA017E318E5/Documents/temp//Welcome.docx

Anyone else have this or other issues with the Quicklook in iOS 6.0? Or any suggestions of what to try? I've tried it via iPhone and iPad with both pushing the controller and presenting it.

Edit: Also just noticed that the URL in question (the one they say is bad) starts with not just file:// but file://localhost whereas the original file just started with an actual path (ie: file:///Users).


Solution

  • Well after a bunch of research and re-creating from the ground-up a basic QuickLook viewer, I found that the error was still logged even from that BUT the documents were actually being displayed which they weren't from my original project.

    I then tried putting the QLPreviewController inside a NavigationController before presenting it and ended up with the same issue. I was wrapping the QLPreviewController in a UINavigationController before presenting it because that seemed to be the way to assign the navigationItem a custom button. That worked fine in iOS 5.1 (as stated above) but apparently iOS 6.0 does not like this.

    Removing the extra code that wrapped the QLPreviewController in a UINavigationController seemed to allow the document to display.

    Example of controller being wrapped:

    QLPreviewController* previewer = [[QLPreviewController alloc] init];
    previewer.dataSource = self;
    previewer.delegate = self;
    [previewer setCurrentPreviewItemIndex:0];
    
    UINavigationController* previewNavCtrl = [[UINavigationController alloc] init];
    [previewNavCtrl pushViewController:previewer animated:NO];
    
    [self presentModalViewController:previewNavCtrl animated:YES];
    

    Change to:

    QLPreviewController* previewer = [[QLPreviewController alloc] init];
    previewer.dataSource = self;
    previewer.delegate = self;
    [previewer setCurrentPreviewItemIndex:0];
    
    [self presentModalViewController:previewer animated:YES];
    

    Note: again the Proxy error still seems to show up in the log however

    ALSO: Any UIBarButtonItem customizations seem to no longer work without the NavigationController =/

    UPDATE: I found that using fileURLWithpath to generate the fileURL for previewItemAtIndex made the original error go away. However, the same problem occurs still where the document will not load.

    A new error (one I've seen other people having as well) is:

    Couldn't issue file extension for path: /Users/me/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/339DDF48-AF93-41B5-B81E-A39440A131C6/Documents/temp/Welcome1.docx

    FINAL UPDATE: Ok the extension issue/error was because I was trying to manually add %20 to the spaces (using [NSString stringByAddingPercentEscapesUsingEncoding] etc) when the [NSURL fileURLWithPath] must handle that already. Once I removed that, this worked and I am now on iOS 6 yay! So the real problem was nothing to do with the UINavigationController but actually the file URL being passed via previewItemAtIndex.