I want to access a PDF file in a folder just to open the PDF file. When opening the UIDocumentPickerViewController, I want to open the target folder directly in which the file is stored. With the directoryURL property I try to enter the target URL directly so that it is taken over by the DocumentPickerViewController, but this only opens the default folder structure. If I change the initializer of the Document PickerView to "for Opening ContentTypes: [.folder]", then it jumps to the right folder, but I can't see any PDF files because it only shows me the folder files.
BUT! : When I test my code via the simulator, my function works. And when I simulate it on my iPhone, the DomumentPickerView keeps jumping to the default folder structure.
struct DocumentPicker : UIViewControllerRepresentable {
@Binding var folderURL : URL?
@Binding var documentURL : URL?
func makeUIViewController(context: Context) -> UIDocumentPickerViewController {
let viewController = UIDocumentPickerViewController(forOpeningContentTypes: [.pdf], asCopy: true)
viewController.delegate = context.coordinator
viewController.directoryURL = folderURL
return viewController
}
func updateUIViewController(_ uiViewController: UIDocumentPickerViewController, context: Context) {
print("Update View")
}
}