This item was deprecated in version 2020r2. Please use MobileImagePicker as a replacement.
The iOSPicturePicker allows selection of an image stored on the device (or taken with the camera) for use in the app.
These are the source locations from which the user can select a picture.
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.
Lets the user choose from the pictures saved in the camera roll.
Lets the user choose a picture from anywhere on the device (albums, camera roll, etc).
Handle As Ptr
Used for creating Declares to the underlying UIImagePickerController.
This property is read-only.
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
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
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:
The user cancelled the picking operation.
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
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">
<string>Allow user to access the camera.</string>
iOS projects on the iOS operating system.