Mar*_*nig 2 pdfkit swift ios11
我正在使用 Apple 的 PDFKit 开发一个应用程序,并设法放置了一些带有工作的注释按钮,PDFActionURL在点击它们后打开 iOS 标准浏览器。
不幸的是,我没有找到一个可行的解决方案,即如何在应用内浏览器中打开相关链接或在 web 视图中加载它。点击 AnnotationButton 后,PDFKit 会自动打开 Safari,我还没有找到有关 iOS 的属性或其他方式来通过操作 PDFAction 来影响此行为。
let urlString = "https://www.apple.com"
let urlAction = PDFActionURL(url: urlString)
urlButton.action = urlAction
pdfPage.addAnnotation(urlButton)
Run Code Online (Sandbox Code Playgroud)
有没有办法强制每次调用 In-App-BrowserUIApplication.shared.open()或操纵 a 的执行PDFAction?
最后,我自己想通了;) 我忽略了PDFViewDelegate 的一个功能
通过将 pdfView 的委托设置为所涉及的 ViewController 并使用此功能
func pdfViewWillClick(onLink sender: PDFView, with url: URL) {
print(url)
}
Run Code Online (Sandbox Code Playgroud)
您可以使用 PDFActionButton 的关联 URL 并触发应用内浏览器(例如 SFViewController)。
| 归档时间: |
|
| 查看次数: |
789 次 |
| 最近记录: |