The camera is probably the most widely used feature of an iOS device. In this section, we will cover the most frequently used Camera events by creating an application that will allow us to take a picture using the Camera device and to select a picture from the Gallery.
An iPhone implements image selection through a picker that allows us to get images from different sources, such as Camera Roll or Photo Library. The UIImagePickerController
class provides basic, customizable user interfaces (UIs) for taking pictures and videos, also providing the user with some simple editing capabilities for newly captured media.
The role and appearance of a UIImagePickerController
class depends on the value of sourceType
assigned to it. There are three ways to choose the source of an image, as follows:
Choose from Camera:
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
Choose from any folder in Gallery:
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary...