首页 > 解决方案 > 按下按钮 Swift 后打开可滚动的 pdf

问题描述

我想知道这是否可能?我希望我的用户点击一个按钮,例如“了解更多”

let findOutMoreButton: UIButton = {
let button = UIButton()
button.setTitle("Find out more", for: .normal)
button.addTarget(self, action: #selector(handleTapped), for: .touchUpInside)
return button
}()

@objc func handleTapped() {
//This will bring the user to the scrollable .pdf via pushViewController
}

所以我有这个按钮,当用户点击它时,为了了解更多信息,pushViewController 会将它们带到一个可滚动的 pdf 文件中,其中包含文本信息。那可能吗?我该怎么做呢?

标签: swiftpdfswift5scrollable

解决方案


如果您在项目中有 pdf 文件或已经下载,那么您可以使用QLPreviewController. 它是来自 iOS 的原生控制器,用于显示文档。

这是一篇关于如何正确实施它的好文章。 https://www.raywenderlich.com/10447506-quicklook-previews-for-ios-getting-started


推荐阅读