Description:
When using UIDocumentPickerViewController
in iOS, if the user taps two or more files in quick succession, the picker view controller dismisses itself automatically twice. This results in an unintended behavior, leading to inconsistent screen states or redundant dismiss animations.
Steps to Reproduce:
-
Initialize a
UIDocumentPickerViewController
instance inUIDocumentPickerModeImport
.UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[(NSString *)kUTTypeData] inMode:UIDocumentPickerModeImport]; documentPicker.delegate = self; documentPicker.modalPresentationStyle = UIModalPresentationFullScreen; documentPicker.allowsMultipleSelection = NO; [self presentViewController:documentPicker animated:YES completion:nil];
-
Launch the document picker.
-
Quickly tap two or more files in succession.
Expected Behavior:
- The
UIDocumentPickerViewController
should dismiss once and call the delegate methoddocumentPicker:didPickDocumentsAtURLs:
with the selected file(s).
Actual Behavior:
- The
UIDocumentPickerViewController
automatically dismisses twice. - This issue occurs even when no explicit call to
dismissViewControllerAnimated:
is made in the delegate method.
Observed Results:
- The
didPickDocumentsAtURLs:
callback is invoked after the picker is already dismissed. - During this process, unintended behavior such as multiple dismiss animations, view controller state corruption, or UI inconsistencies may occur.
Impact:
- This issue disrupts the user experience and causes UI glitches when selecting documents.
- It prevents developers from having full control over dismiss behavior or mitigating the problem programmatically.
Environment:
- iOS Version: iOS 15.0 and later (also reproduced on iOS 17.4)
- Device: Reproducible on multiple iPhone and iPad models
- Framework: UIKit
Conclusion:
This appears to be a system-level issue with UIDocumentPickerViewController
. The automatic dismiss behavior is not correctlyhandling multiple taps, causing unintended dismiss events. Developers have no explicit way to prevent this behavior or gain full control over the dismissal process.
We kindly request Apple to investigate and resolve this issue to ensure UIDocumentPickerViewController
behaves as expected when interacting with multiple taps.