Chapter 10. Camera and the Photo Library

10.0. Introduction

Devices running iOS, such as the iPhone, are equipped with cameras—for instance, the iPhone 4 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 (in iOS SDK 2.0 and later) 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.


iPhone Simulator does not support the Camera interface. Please test and debug all your applications that require a Camera interface on a real device. All the examples in this chapter are run on three devices: the iPhone 3GS, iPhone 4, and iPad (the iPad does not have a camera, but we are including it in this chapter to see if our code really can detect the availability of a camera on an iOS device).

In this chapter, first we will attempt to determine if a camera is available on the iOS device that is running our application. You can also determine whether the camera allows you (the programmer) to capture videos, images, or both. To ...

Get iOS 4 Programming Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.