3

I've got some simple code showing a simple PDF, using QLPreviewController. It works great in the simulator, and in a very simple app.

In the app I actually want it to work in, it fails on the device. The device shows the preview view, but in place of the PDF it simply shows the text "simple.pdf, Portable Document Format (PDF)" and the size of the file ("301KB" in this case).

Interestingly, the log emits "Failed to load quicklookd with error : The operation couldn’t be completed. (Cocoa error 4097.)"

I've tried:

  • A couple of PDFs, a simple one full of text, and a the IRS' W4 PDF. Same results.
  • UIDocumentInteractionController instead. Same results.

Ruled out:

  • I am linking with QuickLook.framework in build phases.
  • [QLPreviewController canPreviewItem:] returns YES.

My view heirarchy is not terribly complex; a UINavigationController fronting a SWRevealViewController. Doesn't matter how shallow or deep I am in the navigation hierarchy when the PDF is Quicklook'd.

I'm out of ideas and am hoping someone recognizes the error.

edit: app works fine on an iOS 6 device. Works in the simulator on 6.1, 7.0, and 7.1. Fails on a 7.0 device, argh!

Graham Perks
  • 23,007
  • 8
  • 61
  • 83

2 Answers2

2

This is an issue on 64bit devices. You can replicate it in the 64 bit iOS 7 simulators. The same error with other frameworks is reported here :

Cannot show modal ViewController in iOS7

Updating the architectures setting in build settings to 'Standard architectures (including 64-bit) (armv7, armv7s, arm64)' aka $(ARCHS_STANDARD_INCLUDING_64_BIT) will fix the issue. That is of course if you have compatible versions of all your 3rd party libraries.

For reasons only apple engineers could know, removing different appearance delegate changes also provides a workaround up through iOS 7.0.4 at least. In my case the appearance change that brought about the issue is

[[UITableView appearance] setSeparatorInset:UIEdgeInsetsZero];

Community
  • 1
  • 1
user564904
  • 216
  • 2
  • 6
  • This is the exact solution that solved it for me. I even had the table view appearance separator inset too - removing this was a temporary workaround. Building the arm64 slice is the proper solution. But it means you have to get arm64 slices for any 3rd party libraries in use too - either by updating to their latest version (if available), or building from source code with arm64 support enabled. That's if you have the source code! – Rob B Feb 14 '14 at 03:04
1

Finally narrowed it down to this line, which is called early during app launch.

Oddly, adding this line alone to a simple app doesn't cause the failure, so there's some other additional interaction happening that I can't find.

Sadly not a proper explanation, but at least I can now move on. Hopefully this answer'll save someone else some time!

// We don't want Back button text, move it off-screen
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60.f) forBarMetrics:UIBarMetricsDefault];
Graham Perks
  • 23,007
  • 8
  • 61
  • 83