How to select a UIImage from the camera roll (and use it)

The UIImagePickerController can help us do this with ease.

In this example we’ll instantiate it, then we tell it what kind of image we want returned (we’re using an edited version here, but we could just as well return the original, or start using a camera). Next we present a modal view controller where the actual image selection takes place:

For this to work you need to conform to the UIImagePickerControllerDelegate protocol, as well as the UINavigationControllerDelegate (the latter does not need any methods – it’s just so that the warning to myPicker.delegate = self goes away really).

The two methods we need from the first protocol are to deal with a selection and a cancellation. In this example I’m displaying the returned image in a UIImageView:

About Jay Versluis

Jay is a medical miracle known as Super Survivor. He runs several YouTube channels and websites, and he's also live on Twitch sometimes. To support him on his mission to make the world a better place, you can support him on Patreon or buy him a coffee.

Add your voice!