-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS: File picker cannot be opened in another sheet #164
Comments
Hi @davidsoukup! Thanks for submitting this issue! Could you share a project that reproduces it? It would be easier for me to replicate your behavior. |
It can be easily replicated in sample project, there is code for iOSApp in sample directory to replicate the issue.
|
Related to #164 Fix the file picker function to work correctly when called in another sheet without causing a presentation error. * **ContentView.swift** - Update the `sheet` modifier to dismiss any currently presented view controller before presenting the picker. - Add a check to ensure the picker is not presented on a view controller that is already presenting another view controller. * **FileKit.ios.kt** - Update the `callPicker` function to dismiss any currently presented view controller before presenting the picker. - Add a check to ensure the picker is not presented on a view controller that is already presenting another view controller. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/vinceglb/FileKit/issues/164?shareId=XXXX-XXXX-XXXX-XXXX).
Thanks for your sample code. I found that it's not possible to display multiple view controllers at the same time. A common solution is to dismiss the currently active view controller and display the document picker after that. Here is the result from the PR #170 implementing the changes: CleanShot.2024-12-11.at.12.54.08.mp4Does it solve your issue? Is it a problem that it dismisses the first sheet? |
@theHonzic, what is the best way to manage this case? I'm open to any suggestion! |
@vinceglb Thanks for the quick iteration, unfortunately this won't help our case. We have a flow in sheet that requires files to be uploaded in one of the steps, closing the original sheet is not an option for us. I will leave this issue open for now and try to find a solution during this week. |
I'm trying to implement a file picker for iOS.
I have implemented the file picker function in the View model:
Then, I have this component in iOS.
PepFormFileUpload( onSelect: { viewModel.setEvent(event: PepFormContractEventSelectDocument(document: document)) }, requiredDocument: requiredDocument, selectedFiles: viewModel.state.requiredDocuments[requiredDocument] as? [Filekit_corePlatformFile] )
Selecting files works, but when calling SelectDocument in another sheet, this error occurs:
Attempt to present <UIDocumentPickerViewController: 0x10192ce00> on <_TtGC7SwiftUI19UIHostingControllerGVS_15ModifiedContentVS_7AnyViewVS_12RootModifier__: 0x10202aa00> (from <_TtGC7SwiftUI19UIHostingControllerGVS_15ModifiedContentVS_7AnyViewVS_12RootModifier__: 0x10202aa00>) which is already presenting <_TtGC7SwiftUI29PresentationHostingControllerVS_7AnyView_: 0x10985a800>.
iOS 18.1 & Xcode 16.0
The text was updated successfully, but these errors were encountered: