Class
iOSPicturePicker
Warning
This item was deprecated in version 2020r2. Please use MobileImagePicker as a replacement.
Description
The iOSPicturePicker allows selection of an image stored on the device (or taken with the camera) for use in the app.
Methods
Name |
Parameters |
Returns |
Shared |
---|---|---|---|
parentView As MobileScreen |
Enumerations
iOSPicturePicker.Sources
Sources
These are the source locations from which the user can select a picture.
Enum |
Description |
---|---|
Camera |
The user is prompted to take a picture with the camera. When running in the iOS Simulator an UnsupportedOperationException is raised if you try to use Camera. |
CameraRoll |
Lets the user choose from the pictures saved in the camera roll. |
PhotoLibrary |
Lets the user choose a picture from anywhere on the device (albums, camera roll, etc). |
Property descriptions
iOSPicturePicker.Handle
Handle As Ptr
Used for creating Declares to the underlying UIImagePickerController.
This property is read-only.
iOSPicturePicker.IsEditable
IsEditable As Boolean
Indicates if the user can edit the picture in the picker.
Display a picture picker that lets the user edit the picture they select:
MyPicPicker.IsEditable = True
MyPicPicker.Source = iOSPicturePicker.Sources.CameraRoll
MyPicPicker.Show
iOSPicturePicker.Source
Source As Sources
Uses the Sources enumeration to specify the source for the pictures to select from.
Prompt the user to take a picture:
MyPicPicker.Source = iOSPicturePicker.Sources.Camera
MyPicPicker.Show
Method descriptions
iOSPicturePicker.Show
Show(parentView As MobileScreen)
Displays the picture picker.
This is not modal so your code continues running after calling Show. The Cancelled and Selected events are called based on the user's action.
Display the picture picker:
MyPicPicker.Show(Self)
Event descriptions
iOSPicturePicker.Cancelled
Cancelled
The user cancelled the picking operation.
iOSPicturePicker.Selected
Selected(pic As Picture)
Called when a picture is selected. pic is an iOSBitmap that can then be used by the app.
Display the selected picture:
MyImageView.Image = pic
Notes
2018r3 and later automatically add the NSCameraUsageDescription key to the plist.
If your source is set to Sources.Camera and you're using an earlier version of Xojo, then you will also need to add a plist entry to tell iOS to allow camera access.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSCameraUsageDescription</key>
<string>Allow user to access the camera.</string>
</dict>
</plist>
Compatibility
iOS projects on the iOS operating system.