From Camera Roll
PhotoEditor SDK supports importing photos from the camera roll.
Instantiate image picker#
To that end, we first instantiate a UIImagePickerController
. We are opting for this class over PHPickerViewController
, because the latter does not reliably work for some .mp4
files encoded with non-ffmpeg codecs.
We have reported this issue to Apple.
We further set the current class as the controller's delegate to handle cancellation. Since we only want photos from the camera roll, we set sourceType
and mediaType
correspondingly.
Initialize the editor#
The imagePickerController
delegate is invoked when the user picked a photo and the photo object is passed to it as originalImage
via the info dictionary.
We can now dismiss the image picker and create a Photo
from the image
which is, in turn, passed as photoAsset
to the PhotoEditViewController
to instantiate the photo editor.
Again, setting the current class as the delegate of the PhotoEditViewController
allows us to implement export, cancellation and error handling there.