O'Reilly logo

iOS 7 Programming Cookbook by Vandad Nahavandipoor

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 15. Camera and the Photo Library

15.0. Introduction

Most devices running iOS, such as the iPhone, are equipped with cameras. The most recent iPhone has two cameras, and some iPhones may only have one. Some iOS devices may not even have a camera. 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 whether 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. Simply import its umbrella framework into your application like so:

#import "AppDelegate.h"
#import <MobileCoreServices/MobileCoreServices.h>

@implementation AppDelegate

<# Rest of your code goes here #>

We will then ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required