4

Is PDF Link handling available in Quicklook?

I created a prototype, and the QLPreviewControllerDelegate method -(BOOL)previewController:(QLPreviewController *)controller shouldOpenURL:(NSURL *)url forPreviewItem:(id)item never gets called.

When I use a .docx file with links in it, the delegate method does get fired.

Also, when I open up the PDF using safari, or a UIWebView, link handling works fine.

I tested with a few different PDFs, and link interception never worked.

I made sure that My interface implements the following protocols: QLPreviewControllerDataSource, QLPreviewControllerDelegate

I also made sure that the class that has the shouldOpenUrl method is assigned as the delegate to my QlPreviewController instance.

I am guessing the issue is not with my code, since the .docx link interception works fine.

Any thoughts on what I might be doing wrong?

Is PDF Link interception even supported by Quicklook?

I also noticed that when I open up a PDF in iOS mail, it uses Quicklook, and PDf links don't work there either.

4

2 回答 2

2

为那些在这里寻找相同答案的人回答我自己的问题。Quicklook 不支持链接处理。如果您需要处理 PDF 文档中的链接,则必须使用 CATiledLayer 来呈现 PDF。

于 2012-05-30T05:50:47.603 回答
0

您可以通过以下方式检测何时单击文档中的链接QLPreviewControllerDelegate

/*
 * @abstract Invoked by the preview controller before trying to open an URL tapped in the preview.
 * @result Returns NO to prevent the preview controller from calling -[UIApplication openURL:] on url.
 * @discussion If not implemented, defaults is YES.
 */
- (BOOL)previewController:(QLPreviewController *)controller shouldOpenURL:(NSURL *)url forPreviewItem:(id <QLPreviewItem>)item;

返回YES将打开该文档,如果它是外部 URL,它将自动启动 Safari。

请注意,您可能希望显示 UIAlertView 以询问用户是否要退出应用程序以打开 Safari。

于 2013-03-19T01:15:18.647 回答