QLPreviewController: quicklookd failing to load

独自空忆成欢 提交于 2019-12-23 19:13:16

问题


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!


回答1:


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];




回答2:


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];


来源:https://stackoverflow.com/questions/20411489/qlpreviewcontroller-quicklookd-failing-to-load

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!