PHPickerConfiguration
PHPickerConfiguration represents the configuration of the photo picker: how many items can be selected at most, which types are shown, how selection works, and what the picker looks like.
The configuration is copied when a PHPickerViewController is created. Changing the configuration object afterwards doesn't affect pickers already created. Its properties have no change notifications: only the app can change them.
You need to install @nacrejs/photos first; for how, see PHPickerViewController, or see Core and capability packages.
Inheritance: NSObject → PHPickerConfiguration
Constructor
Creates a configuration with all default values: at most 1 item, all types shown.
Instance properties
| Property | Description |
|---|---|
selectionLimit | The maximum number of items. 0 means no limit |
filter | Which types are shown. null means all |
preferredAssetRepresentationMode | Which format to give when an item has several |
selection | How selection works: checkmarks, numbers, notification on every selection |
mode | What the picker looks like: full, or just a row of thumbnails |
Examples
const config = new PHPickerConfiguration();
config.filter = PHPickerFilter.imagesFilter;
config.selectionLimit = 9;
config.selection = 'ordered';
const picker = new PHPickerViewController(config);Effect: creates a photo picker that, once presented, shows only images, allows up to 9 to be selected, and shows on each selected image the order in which it was selected. The on-screen effect is not verified in the simulator.
Corresponding iOS API
| ObjC | JS |
|---|---|
[[PHPickerConfiguration alloc] init] | new PHPickerConfiguration() |
config.selectionLimit = 3 | config.selectionLimit = 3 |
config.filter = PHPickerFilter.imagesFilter | config.filter = PHPickerFilter.imagesFilter |
config.selection = PHPickerConfigurationSelectionOrdered | config.selection = 'ordered' |
See also
PHPickerViewController: creating a photo picker with this configurationPHPickerFilter: the type offilter- Picking photos and saving them to the photo library