In keeping with the weird issues experienced with the SwiftUI fileImporter modifier recently (please see "SwiftUI fileImporter not updating binding on dismissal" for details on that other issue), here's the latest strange observed behaviour using the exact same code as this previous question:
struct ContentView: View {
@State private var showFileImporter: Bool = false
var body: some View {
VStack {
Button("Pick Some Files...") {
showFileImporter.toggle()
}
}
.fileImporter(
isPresented: $showFileImporter,
allowedContentTypes: [.movie, .audio, .image],
allowsMultipleSelection: true,
onCompletion: { result in
/* ...some code here */
})
}
}
When run in iPadOS 14 using either the iPad simulator or on an actual iPad device (this was tested with the iPhone simulator and an actual iPhone and I believe, thou not 100% sure, this DOES NOT happen on iOS 14), either from a "fresh" install or not, the first time the document picker is triggered just shows a modal view (with the right dimensions) that looks almost ok EXCEPT it is totally blank - it won't even show the top buttons (cancel, etc.)
If you then dismiss the view by tapping outside of it, and present it again, THEN it shows correctly, with the complete UI and the actual files (say, visible on the "On My iPad" view), letting you pick files, etc. and from there on working correctly UNTIL you stop or restart the app again, when the behaviour returns.
I suppose this could be a bug? Yet it feels to me, in my ignorance, like something is not being "set" on this first run (like the initial directory that the document picker should use) and that after this first run, something in the "environment" gets set that then the picker can use.
Also: I can't find any documentation anywhere explaining how I could, for example, set the initial "directory" that the document picker pops up in - i.e., if I wished to offer to pick from one of the cloud providers directly, without the user having to select it in the document browser - and as of now I don't really know if this is even possible with this modifier.
Any help or pointers is greatly appreciated.