0

嗨,我正在我的应用程序中开发一个 documentBrowser ViewController,以便用户可以浏览 documentDirectoy 中的文件和文件夹我想知道有没有办法实现 UIDocumentBrowser 来打开应用程序 documentDirectory?

4

1 回答 1

0

首先,当你想打开 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)
           }
        }
    }
于 2020-11-10T09:55:10.470 回答