hi i am developing a documentBrowser ViewController in my app so that user can browse files and folders inside documentDirectoy i was wondering is there any way to implement UIDocumentBrowser to open apps documentDirectory?
Asked
Active
Viewed 252 times
0
-
Do you want to open Apple Default "Files" app for browsing files, Folders etc..?? – Kudos Nov 10 '20 at 06:25
-
i dont want to open files app instead i want to gave a view controller inside app to browse files and folders inside – Mamad Nov 10 '20 at 06:56
1 Answers
0
First,Call this function when you want to open DocPicker.
func openDoc() {
let documentPicker = UIDocumentPickerViewController(documentTypes:
["public.text",
kUTTypePDF as String,
"public.composite-content",
], in: .open)
documentPicker.delegate = self
}
Secondly, Add Delegate in your class.
extension DemoViewController: UIDocumentPickerDelegate {
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
if var url = urls.first {
//Do something with url.
print(url)
}
}
}

Kudos
- 1,224
- 9
- 21