Difference between revisions of "UIImagePickerController"

From iPhone Development Wiki
Jump to: navigation, search
(Curate!)
(+ fixes, changing point of view, grammar, etc.)
Line 1: Line 1:
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]].
+
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 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.  Its primary use is to get photos and insert them into a [[UIImageView]].
  
 
== Image storage ==
 
== Image storage ==
Line 5: Line 5:
  
 
== Presentation of the controller ==
 
== 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 <blockquote>[picker presentModalViewControllerAnimated:YES];</blockquote> would present it.
+
On an iPhone or iPod touch, the UIImagePickerController should be set up to present from a modal view controller, and its delegate should be itself.  It is necessary to present the material on a modal view controller, so that <blockquote>[picker presentModalViewControllerAnimated:YES];</blockquote> can present it.
On an iPad, the UIImagePickerController MUST be presented in a [[UIPopoverController]].  The best way to do this is to do <blockquote>[[UIPopoverController alloc] initWithContentViewController: imagePicker]</blockquote> where UIImagePickerController is defined as imagePicker.
+
On an iPad, the UIImagePickerController MUST be presented in a [[UIPopoverController]].  The best way to do this is by utililizing <blockquote>[[UIPopoverController alloc] initWithContentViewController: imagePicker]</blockquote> where UIImagePickerController is defined as imagePicker.
  
 
== Dismissing ==
 
== 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.
+
It is also necessary to not forget to include the didCancel method, and make sure to tell it to dismiss the controller after finishing or picking an image.
  
  

Revision as of 06:32, 21 January 2014

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 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. Its 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 its delegate should be itself. It is necessary to present the material on a modal view controller, so that

[picker presentModalViewControllerAnimated:YES];

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

[[UIPopoverController alloc] initWithContentViewController: imagePicker]

where UIImagePickerController is defined as imagePicker.

Dismissing

It is also necessary to not forget to include the didCancel method, and make sure to tell it to dismiss the controller after finishing or picking an image.


References