hi我正在我的应用程序中开发一个documentBrowser ViewController,这样用户就可以浏览documentDirectoy中的文件和文件夹。我想知道有没有任何方法可以实现UIDocumentBrowser来打开应用程序documentDirectory?
首先,当您想要打开DocPicker时调用此函数。
func openDoc() {
let documentPicker = UIDocumentPickerViewController(documentTypes:
["public.text",
kUTTypePDF as String,
"public.composite-content",
], in: .open)
documentPicker.delegate = self
}
第二,在你的课堂上添加代理人。
extension DemoViewController: UIDocumentPickerDelegate {
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
if var url = urls.first {
//Do something with url.
print(url)
}
}
}