Chapter 30. Photo Library and Image Capture

The still photos and movies accessed by the user through the Photos app constitute the photo library. Your app can provide an interface for exploring this library, similar to the Photos app, through the UIImagePickerController class. In addition, the Assets Library framework lets you access the photo library and its contents programmatically. The UIImagePickerController class can also be used to provide an interface similar to the Camera app, letting the user take photos and videos on devices with the necessary hardware; and, at a deeper level, AV Foundation provides direct control over the camera hardware.

To use constants such as kUTTypeImage, referred to in this chapter, your app must link to MobileCoreServices.framework and import <MobileCoreServices/MobileCoreServices.h>.

UIImagePickerController

UIImagePickerController is a view controller (UINavigationController) whose view provides a navigation interface, similar to the Photos app, in which the user can choose an item from the photo library. Alternatively, it can provide an interface, similar to the Camera app, for taking a video or still photo if the necessary hardware is present. On the iPhone, you will typically display the view controller’s view as a presented view controller. On the iPad, you’ll show it in a popover; attempting to display it as a presented view controller causes a runtime exception. (To see how to structure your universal app code, look at Example 29-1).

Choosing ...

Get Programming iOS 5, 2nd Edition now with O’Reilly online learning.

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