13.0. Introduction

Devices running iOS, such as the iPhone, are equipped with cameras—for instance, the iPhone 5 has two cameras and the iPhone 3G and 3GS each have one. Some iOS devices, such as the first generation of the iPad, do not have cameras. The UIImagePickerController class allows programmers to display the familiar Camera interface to their users and ask them to take a photo or shoot a video. The photos taken or the videos shot by the user with the UIImagePickerController class then become accessible to the programmer.

In this chapter, you will learn how to let users take photos and shoot videos from inside applications, access these photos and videos, and access the photos and videos that are placed inside the Photo Library on an iOS device, such as the iPod touch and iPad.

Note

iOS Simulator does not support the Camera interface. Please test and debug all your applications that require a Camera interface on a real iOS device with a camera.

In this chapter, we will first attempt to determine if a camera is available on the iOS device running the application. You can also determine whether the camera allows you (the programmer) to capture videos, images, or both. To do this, make sure you have added the MobileCoreServices.framework framework to your target by following these steps:

  1. Click on your project’s icon in Xcode.

  2. Select the target to which you want to add the framework.

  3. On the top of the screen, select the Build Phases tab.

  4. In the Build Phases screen, expand the Link Binary ...

Get iOS 6 Programming Cookbook 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.