Chapter 17. 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 give the user an interface for exploring this library through the UIImagePickerController class.

In addition, the Assets Library framework lets you access the photo library and its contents programmatically. You’ll need to @import AssetsLibrary.

The UIImagePickerController class can also be used to give the user an interface similar to the Camera app, letting the user take photos and videos on devices with the necessary hardware.

At a deeper level, the AV Foundation framework (Chapter 15) provides direct control over the camera hardware. You’ll need to @import AVFoundation (and probably CoreMedia).

Constants such as kUTTypeImage, referred to in this chapter, are provided by the Mobile Core Services framework; you’ll need to @import MobileCoreServices.

Choosing From the Photo Library

UIImagePickerController is a view controller (UINavigationController) providing a navigation interface in which the user can choose an item from the photo library. There are two ways to show this interface:

As a presented view controller
This is the expected approach on the iPhone; it does also work on the iPad. (In earlier versions of iOS, trying to present a UIImagePickerController as a presented view controller on the iPad caused a runtime error; the documentation claims that this is still the case, but it isn’t.) This presented view controller ...

Get Programming iOS 7, 4th Edition now with the O’Reilly learning platform.

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