Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/Variables/includes/ExtVariables.php on line 198
UIImagePickerController: Difference between revisions - iPhone Development Wiki

UIImagePickerController: Difference between revisions

From iPhone Development Wiki
(Created page with 'UIImagePickerController is a view controller responsible for allowing the developer to access the user's photo library, camera roll, saved photos, and the camera itself. It help…')
 
(Curate!)
Line 12: Line 12:




 
== References ==
''Note that this article is a summary and needs to be expanded.''
<references />
* Official documentation: {{sdklink|UIKit|UIImagePickerController}}
{{IPFHeader|UIKit|3=2}}

Revision as of 00:47, 3 June 2010

UIImagePickerController is a view controller responsible for allowing the developer to access the user's photo library, camera roll, saved photos, and the camera itself. It helps to detect if a camera is present and if the camera supports video capture or still capture only. Additionally, the controller allows basic cropping features before sending an image out of the controller. It's primary use is to get photos and insert them into a UIImageView.

Image storage

Images are picked by the user and stored to a NSDictionary object, where the developer can retrieve it. If allowEditing: is enabled, then the developer can pick which image to take from the NSDictionary.

Presentation of the controller

On an iPhone or iPod touch, the UIImagePickerController should be set up to present from a modal view controller, and it's delegate should be itself. You need to present the material on a modal view controller, so

[picker presentModalViewControllerAnimated:YES];

would present it. On an iPad, the UIImagePickerController MUST be presented in a UIPopoverController. The best way to do this is to do

[[UIPopoverController alloc] initWithContentViewController: imagePicker]

where UIImagePickerController is defined as imagePicker.

Dismissing

Do not forget to include the didCancel method, and make sure you tell it to dismiss the controller after finishing or picking an image.


References