I have a WKWebview loading a web based UI where I would like users to be able to upload a file from their iCloud documents. I have granted the correct permissions and I am able to browse the iCloud documents. However when I either select a file or click the cancel button, as well as the document picker view dismissing the parent view of my WKWebview is also dismissed.
I have tried to track the dismiss path. I am 100% sure I am not calling the dismiss function on my view.
Does anyone have any idea what is triggering the dismiss on my WKWebview container and how to prevent it?
I had the same problem on Objective-C and iOS11 with WKWebView and solved it using this workaround. You should be able to migrate it to Swift easily :
inside this view controller add this weak property
@property (weak, nonatomic) UIDocumentPickerViewController *_Nullable docPickerPtr;
inside same view controller override these two methods originally part of the UIViewController base class
what we do is :