- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有两个问题,在 google 上搜索了 5 天后仍找不到答案。
在 uidocumentpicker
的帮助下,我曾经访问文件并选择 pdf 文档。在 didpicdocuments
方法的帮助下选择 pdf 后,我得到了 pdf 的 URL 并将其存储到一个数组中。并在表格 View 中显示一行,其中包含该 pdf 的名称。现在,当用户单击该行时,pdf 在 pdfkit
的帮助下打开,该 URL 存储在该数组中。到目前为止一切正常。现在问题出在两三分钟后,当我再次点击该行时,它没有打开该 pdf,它只会打开一个空白的 pdfview
。
在打开选择 pdf 时,我只想选择 pdf 文件,而不是其他文件,为此,我使用了移动核心服务,并在文档选择器的文档类型中提到了 pdf 类型。但即使在它之后它也不起作用我也无法选择 pdf 文件。
谢谢
func didSelectDocument(doc: String?) {
let importMenu = UIDocumentPickerViewController(documentTypes: [String("kUTTypePDF")], in: .import)
importMenu.delegate = self
//importMenu.allowsMultipleSelection = true
importMenu.modalPresentationStyle = .formSheet
self.present(importMenu, animated: true, completion: nil)
}
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
if let url = urls.first {
urlArray.append(url)
}
}
用于打开 pdf
let vc = UIViewController()
vc.view.backgroundColor = .white
let pdfView = PDFView(frame: CGRect(x: 0, y: 0, width: vc.view.frame.width, height: vc.view.frame.height))
let pdfDocument2 = pdfDocuments[indexPath.row-(imageSelected.count)]
pdfView.displayMode = .singlePageContinuous
pdfView.autoScales = true
pdfView.document = pdfDocument2.pdf
vc.view.addSubview(pdfView)
navigationController?.pushViewController(vc, animated: true)
最佳答案
您无法保存它们。该 URL 是沙盒中的一个临时漏洞。来自 the docs对于 UIDocumentPickerViewController
Don’t save URLs provided by the open and move operations. You can, however, save a bookmark to these URLs. Call the bookmarkData(options:includingResourceValuesForKeys:relativeTo:) method and pass in the withSecurityScope option, creating a bookmark containing a security-scoped URL.
您需要保存一个 Security Scoped 书签,它本质上是一团 Data
关于ios - 从 UIDocumentPicker 获取的本地 URL 在 2 或 3 分钟后不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59158074/
今天有小伙伴给我留言问到,try{...}catch(){...}是什么意思?它用来干什么? 简单的说 他们是用来捕获异常的 下面我们通过一个例子来详细讲解下
我正在努力提高网站的可访问性,但我不知道如何在页脚中标记社交媒体链接列表。这些链接指向我在 facecook、twitter 等上的帐户。我不想用 role="navigation" 标记这些链接,因
说现在是 6 点,我有一个 Timer 并在 10 点安排了一个 TimerTask。之后,System DateTime 被其他服务(例如 ntp)调整为 9 点钟。我仍然希望我的 TimerTas
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我就废话不多说了,大家还是直接看代码吧~ ? 1
Maven系列1 1.什么是Maven? Maven是一个项目管理工具,它包含了一个对象模型。一组标准集合,一个依赖管理系统。和用来运行定义在生命周期阶段中插件目标和逻辑。 核心功能 Mav
我是一名优秀的程序员,十分优秀!