使用PDFKit点击注释后触发应用内浏览器-iOS 11 [英] Trigger In-App-Browser after tapping on Annotation with PDFKit - iOS 11

查看:71
本文介绍了使用PDFKit点击注释后触发应用内浏览器-iOS 11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Apple的PDFKit开发一个应用程序,并设法将一些Annotation-Buttons与有效的 PDFActionURL 配合使用,在点击它们后会打开iOS标准浏览器.

I´m working on an app with Apple's PDFKit and have managed to put some Annotation-Buttons with a working PDFActionURL, which open the iOS standard browser after tapping on them.

不幸的是,我找不到有效的解决方案,即如何在应用内浏览器中打开关联的链接或如何将其加载到Web视图中.轻按AnnotationButton后,PDFKit会自动打开Safari,但我还没有找到有关iOS的属性或其他方式来通过操纵f来影响此行为.PDFAction.

Unfortunately, I did not find a working solution, how to open the associated links in an In-App-Browser or to load it in a webview. After tapping the AnnotationButton PDFKit automatically opens Safari and I haven´t found a property or another way concerning iOS to influence this behavior by manipulating f.e. the PDFAction.

let urlString = "https://www.apple.com"
let urlAction = PDFActionURL(url: urlString)
urlButton.action = urlAction
pdfPage.addAnnotation(urlButton)

是否有一种方法可以在每个 UIApplication.shared.open()处强制调用In-App-Browser或操纵 PDFAction 的执行?

Is there a way to force the call of an In-App-Browser at every UIApplication.shared.open() or to manipulate the execution of a PDFAction?

推荐答案

最后,我自己解决了这个问题;)我忽略了

Finally, I figured it out for myself ;) I´ve overlooked one function of the PDFViewDelegate

通过将pdfView的委托设置为所涉及的ViewController并使用此功能

By setting the delegate of the pdfView to the involved ViewController and using this function

func pdfViewWillClick(onLink sender: PDFView, with url: URL) {
        print(url)
}

您可以使用PDFActionButton的关联网址并触发应用内浏览器(例如SFViewController).

you are able to use the associated URL of the PDFActionButton and to trigger an In-App-Browser (e.g. SFViewController).

这篇关于使用PDFKit点击注释后触发应用内浏览器-iOS 11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆