PHPickerViewControllerFinishEvent
PHPickerViewControllerFinishEvent represents the user finishing a choice in the system photo picker, or tapping Cancel.
The pick event of PHPickerViewController is this class, and results is the items chosen; it is an empty array when the user tapped Cancel.
It belongs to the @nacrejs/photos package; for installation, see PHPickerViewController.
Inheritance: Event → PHPickerViewControllerFinishEvent
Constructor
PHPickerViewControllerFinishEvent()
Creates a PHPickerViewControllerFinishEvent. The runtime creates one itself when it fires the events below; app code can use it to build an event object and fire it with dispatchEvent() to try out a listener.
Instance properties
Also inherits the properties of Event; the most commonly used are type and target. The properties below are read-only; assigning to them throws TypeError.
| Property | Description |
|---|---|
results read-only | The items chosen |
These properties live on the prototype, not on the event object itself: Object.keys(event) and { ...event } don't include them, so read them one by one. See Events with fields.
Events that use this class
| Object | Events |
|---|---|
PHPickerViewController | pick |
It can't be canceled: cancelable is false, and preventDefault() has no effect. The photo picker doesn't close itself; call dismissViewController() in the listener.
Examples
const page = new UIViewController();
const picker = new PHPickerViewController(new PHPickerConfiguration());
picker.addEventListener('pick', (e) => {
console.log(e instanceof PHPickerViewControllerFinishEvent, e.results.length);
picker.dismissViewController({ animated: true });
});
page.presentViewController(picker, { animated: true });Effect: after the user chooses or cancels, prints true and the number chosen, then closes the picker.
Corresponding iOS API
| ObjC | JS |
|---|---|
picker:didFinishPicking: | The pick event |
The results parameter | event.results |
See also
PHPickerViewController: the object that fires this eventPHPickerResult- Picking photos and saving them to the photo library