UIDocumentPickerViewController is dismissed when its delegate documentPicker:didPickDocumentAtURL: is called.

Originator:bruno
Number:rdar://20638197 Date Originated:21-Apr-2015 09:50 PM
Status:Open Resolved:
Product:iOS SDK Product Version:8.2
Classification:Serious Bug Reproducible:Always
 
Summary:
UIDocumentPickerViewController is dismissed before its delegate documentPicker:didPickDocumentAtURL: is called. This is a breaking change in iOS 8.2 and is inconsistent with the UIImagePickerController.

- Breaking change breaking existing code
- Breaks the ability to select multiple files in UIDocumentPickerViewController 
- Inconsistent with the UIImagePickerController: the UIImagePickerController lets the user of this API dismiss the view controller when needed

Expected Results:
UIDocumentPickerViewController should not be dismissed when its delegate documentPicker:didPickDocumentAtURL: is called. The developer should be responsible for dismissing it with code such as:

- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url {
    [controller.presentingViewController dismissViewControllerAnimated:YES completion:^{
        [self didPickLocalURL:url];
    }];
}

Actual Results:
When the delegate method is called, the controller has been dismissed.

Regression:
This is a breaking change because old code that would properly dismiss the controller such as above is now calling dismissViewControllerAnimated:completion: on nil => no result.

- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url {
    [controller.presentingViewController dismissViewControllerAnimated:YES completion:^{
        [self didPickLocalURL:url];
    }];
}

Comments

My bad, this is in 8.3.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!