iOS Reference Library Apple Developer
Search

UIImagePickerControllerDelegate Protocol Reference

Conforms to
Framework
/System/Library/Frameworks/UIKit.framework
Availability
Available in iOS 2.0 and later.
Declared in
UIImagePickerController.h

Overview

The UIImagePickerControllerDelegate protocol defines methods that your delegate object must implement to interact with the image picker interface. The methods of this protocol notify your delegate when the user either picks an image or movie, or cancels the picker operation.

The delegate methods are responsible for dismissing the picker when the operation completes. To dismiss the picker, call the dismissModalViewControllerAnimated: method of the parent controller responsible for displaying the UIImagePickerController object.

To save a still image to the user’s Saved Photos album, use the UIImageWriteToSavedPhotosAlbum function. To save a movie to the user’s Saved Photos album, use the UISaveVideoAtPathToSavedPhotosAlbum function.

Tasks

Closing the Picker

Instance Methods

imagePickerController:didFinishPickingMediaWithInfo:

Tells the delegate that the user picked a still image or movie.

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

Parameters
picker

The controller object managing the image picker interface.

info

A dictionary containing the original image and the edited image, if an image was picked; or a filesystem URL for the movie, if a movie was picked. The dictionary also contains any relevant editing information. The keys for this dictionary are listed in “Editing Information Keys.”

Discussion

Your delegate object’s implementation of this method should pass the specified media on to any custom code that needs it, and should then dismiss the picker view.

When editing is enabled, the image picker view presents the user with a preview of the currently selected image or movie along with controls for modifying it. (This behavior is managed by the picker view prior to calling this method.) If the user modifies the image or movie, the editing information is available in the info parameter. The original image is also returned in the info parameter.

If you set the image picker’s showsCameraControls property to NO and provide your own custom controls, you can take multiple pictures before dismissing the image picker interface. However, if you set that property to YES, your delegate must dismiss the image picker interface after the user takes one picture or cancels the operation.

Implementation of this method is optional, but expected.

Availability
  • Available in iOS 3.0 and later.
Declared In
UIImagePickerController.h

imagePickerControllerDidCancel:

Tells the delegate that the user cancelled the pick operation.

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker

Parameters
picker

The controller object managing the image picker interface.

Discussion

Your delegate’s implementation of this method should dismiss the picker view by calling the dismissModalViewControllerAnimated: method of the parent view controller.

Implementation of this method is optional, but expected.

Availability
  • Available in iOS 2.0 and later.
Declared In
UIImagePickerController.h

Constants

Editing Information Keys

Keys for the editing information dictionary passed to the delegate.

NSString *const UIImagePickerControllerMediaType;
NSString *const UIImagePickerControllerOriginalImage;
NSString *const UIImagePickerControllerEditedImage;
NSString *const UIImagePickerControllerCropRect;
NSString *const UIImagePickerControllerMediaURL;
Constants
UIImagePickerControllerMediaType

Specifies the media type selected by the user.

The value for this key is an NSString object containing a type code such as kUTTypeImage or kUTTypeMovie.

Available in iOS 3.0 and later.

Declared in UIImagePickerController.h.

UIImagePickerControllerOriginalImage

Specifies the original, uncropped image selected by the user.

The value for this key is a UIImage object.

Available in iOS 2.0 and later.

Declared in UIImagePickerController.h.

UIImagePickerControllerEditedImage

Specifies an image edited by the user.

The value for this key is a UIImage object.

Available in iOS 3.0 and later.

Declared in UIImagePickerController.h.

UIImagePickerControllerCropRect

Specifies the cropping rectangle that was applied to the original image.

The value for this key is an NSValue object containing a CGRect opaque type.

Available in iOS 2.0 and later.

Declared in UIImagePickerController.h.

UIImagePickerControllerMediaURL

Specifies the filesystem URL for the movie.

The value for this key is an NSURL object.

Available in iOS 3.0 and later.

Declared in UIImagePickerController.h.




Last updated: 2010-07-13

Did this document help you? Yes It's good, but... Not helpful...