Chapter 30. Photo Library

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 through the UIImagePickerController class. The same class can also be used to take photos and videos on devices with the necessary hardware.

Also, starting in iOS 4, the Assets Library framework lets you access the photo library and its contents programmatically.

You can write files into the Camera Roll / Saved Photos album. The ability to save an image file into the Camera Roll / Saved Photos album, by calling UIImageWriteToSavedPhotosAlbum, has existed since the early days of iOS 2.0. Some kinds of video file can also be saved into the Camera Roll / Saved Photos album; in an example in Chapter 28, I checked whether this was true of a certain video file by calling UIVideoAtPathIsCompatibleWithSavedPhotosAlbum, and saved the file by calling UISaveVideoAtPathToSavedPhotosAlbum, functions that have existed since iOS 3.1. The Assets Library framework adds further options.

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


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 ...

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

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