swift - 按下按钮 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 文件中,其中包含文本信息。那可能吗?我该怎么做呢?
解决方案
如果您在项目中有 pdf 文件或已经下载,那么您可以使用QLPreviewController
. 它是来自 iOS 的原生控制器,用于显示文档。
这是一篇关于如何正确实施它的好文章。 https://www.raywenderlich.com/10447506-quicklook-previews-for-ios-getting-started
推荐阅读
- database - 复杂的 MongoDB 连接查询
- spring - 检索单声道
无阻塞 - java - 将作业配置导入通用作业配置类(Annotation config)
- python - 使用 Beautiful Soup 从表中提取日期
- java - 使用 shell.parse 解析 Groovy 代码会导致大量 java.lang.ClassNotFoundException
- php - 树枝合并错误值“[”的意外标记“标点符号”
- dataframe - PySpark,如何解析格式化为 dict 的字符串并将一些键附加为新列
- ios - IPA 处理失败 Swift5 XCode 12.3
- javascript - 加载页面时如何调用 API 并在 div 中打印值?
- esp32 - 将 Arduino 端口操作转换为 ESP32