2

We have an app that contains a bunch of PDFs in its bundle. When the user taps a button or selects a table cell, we want to display the corresponding PDF in a UIDocumentInteractionController.

This works great on my machine, and on most of the test machines, but I have one user who sees no preview on his iPhone. He sent me a screen shot; the controller has pushed its view onto the navigation stack, and has a working "Action" menu in the nav bar, next to the correct file name. But the big space where the PDF itself should be shown is just a dark gray.

That's on a new iPhone running 6.0.1; on his iPad, also running 6.0.1, it works fine; and on my iPhone 4S running 5.0.1, it works fine. "Works fine" means that it pushes exactly the same surrounding details, including the file name and action menu, but instead of a big gray space, there is a working preview of the PDF.

My view controller hierarchy consists of a tab controller, and within each tab, a navigation controller. The same problem exists both from a table view that's several levels deep in the navigation stack, or from an HTML view that's at the top level of the nav stack. The code to present the controller looks like this:

        self.DIC = [UIDocumentInteractionController interactionControllerWithURL:url];
        self.DIC.delegate = self;
        [self.DIC presentPreviewAnimated:YES];

and the only delegate method implemented is:

- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller {
    if (curTabViewController) return curTabViewController;
    return tabCtrl;
}

This would be returning the current navigation view controller, which I set in tabBarController:didSelectViewController. I can tell that that's working, because the DIC has pushed its view onto the navigation stack, rather than popped up modally.

So. Any idea why UIDocumentInteractionController would be failing to draw a preview on some devices but not others?

UPDATE: I've managed to get this device set up for debugging. The only clue that appears in the log file is this error:

Cannot find preview item for loaded proxy: <QLPreviewItemProxy: 0x1fd67820> - 
file://localhost/var/mobile/Applications/22DDE4EB-6FB6-4364-87D6-E3680E1E1A9B
/agilentJAL.app/BuiltInFiles/help/Getting_Started.pdf

I've searched the interwebs, and found this question, but it doesn't seem to apply in my case. I've double-checked the path and it appears correct (and the DIC menu can successfully email the document, open it in DropBox, etc.) Any idea what else could cause this error?

Community
  • 1
  • 1
Joe Strout
  • 2,634
  • 2
  • 28
  • 39
  • Device free memory? (I have encountered a couple of apps that didn't work well until I did a real restart of my device...though those were rather large apps.) – Phillip Mills Nov 15 '12 at 15:36
  • Rebooting the device didn't help. – Joe Strout Nov 16 '12 at 17:07
  • Here's an interesting thing though... if I change my documentInteractionControllerViewControllerForPreview method to always return tabCtrl (the UITabController which is the root of my controller hierarchy), then it works. No error, and the preview is displayed. But of course then it pops up modally, instead of playing nicely with the navigation stack. Maybe I have to just accept that, but it bugs me that it seems to work fine on every other test device except this one. – Joe Strout Nov 16 '12 at 17:15

1 Answers1

0

Try access navigation controller instead of tab bar. This solved the problem for me. in documentInteractionControllerViewControllerForPreview:​

if let navigationController = self.navigationController {
    return navigationController
} else {
    return self
}
Fabian N.
  • 3,807
  • 2
  • 23
  • 46
P.Zakharov
  • 11
  • 2