Taking Pictures and UIImagePickerController

In the takePicture(_:) method, you will instantiate a UIImagePickerController and present it on the screen. When creating an instance of UIImagePickerController, you must set its sourceType property and assign it a delegate. Since there is setup work needed for the image picker controller, you need to create and present it programmatically instead of through the storyboard.

Setting the image picker’s sourceType

The sourceType constant tells the image picker where to get images. It has three possible values (Figure 14.9):

UIImagePickerControllerSourceType.Camera

The user will take a new picture.

UIImagePickerControllerSourceType.PhotoLibrary

The user will be prompted ...

Get iOS Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.