iOS - UIDocumentMenuViewController presented from within WKWebView dismisses parent view controller

441 Views Asked by At

This question is similar to other questions like this and this, with a few differences:

  1. It concerns UIDocumentMenuViewController instead of UIDocumentPickerViewController. The former has been deprecated in favor of the latter, but the former is still used by the OS on older devices.

  2. The problem only occurs when the user uses "Cancel" to close the document select popup, not when they actually select a file.

Apple seems to have fixed all these bugs in iOS 12 but some are still hanging around in iOS 11.

Like other solutions suggest, I override dismissViewControllerAnimated in my root view controller. It is being called once when the user taps either "Photo Library" or "Browse" to bring up the corresponding view controller. In this case, we relay it onto the superclass:

-(void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion {
    if ( self.presentedViewController) {
        [super dismissViewControllerAnimated:flag completion:completion];
    }
}

But, when the user taps "Cancel", this dismissViewControllerAnimated isn't called at all, yet nevertheless both the file select view controller and my presenting view controller are dismissed. So I'm not sure a proper solution could even be located here.

0

There are 0 best solutions below