no didCancel in PHPickerViewControllerDelegate?

There's only a single function under PHPickerViewControllerDelegate which is didFinishPicking according to the documentation. How do I implement dismiss for the Cancel button that comes along when tapping out with PHPickerViewController?

Have no problem if continue using UIImagePickerControllerDelegate, as it comes with imagePickerControllerDidCancel . However, if I were to implement with the new PHPickerViewController that currently only have a single function, how to enable proper dismiss right on the click of Cancel button instead of just relying the swipe down to dismiss the screen. Kindly advise. Thanks.

Replies

Hello,

picker(_:didFinishPicking:) is also called when the cancel button is pressed, and in this case the results array will be empty. So, if you get an empty results array, you can dismiss the picker.