Questions tagged [uiimagepickercontroller]

Questions related to the iOS UIImagePickerController class (and the associated UIImagePickerControllerDelegate protocol), which provides system-supplied user interfaces for taking pictures and movies on iOS devices, and for choosing saved images and movies.

The UIImagePickerController class manages customizable, system-supplied user interfaces for taking pictures and movies on supported devices, and for choosing saved images and movies for use in your app. An image picker controller manages user interactions and delivers the results of those interactions to a delegate object.

The role and appearance of an image picker controller depend on the source type you assign to it before you present it.

  • A sourceType of UIImagePickerControllerSourceTypeCamera provides a user interface for taking a new picture or movie (on devices that support media capture).
  • A sourceType of UIImagePickerControllerSourceTypePhotoLibrary or
    UIImagePickerControllerSourceTypeSavedPhotosAlbum provides a user
    interface for choosing among saved pictures and movies.

To use an image picker controller containing its default controls, perform these steps:

  1. Verify that the device is capable of picking content from the desired source. Do this calling the isSourceTypeAvailable: class method, providing a constant from the “UIImagePickerControllerSourceType” enum.
  2. Check which media types are available, for the source type you’re using, by calling the availableMediaTypesForSourceType: class method. This lets you distinguish between a camera that can be used for video recording and one that can be used only for still images.
  3. Tell the image picker controller to adjust the UI according to the media types you want to make available—still images, movies, or both—by setting the mediaTypes property.
  4. Present the user interface by calling the presentViewController:animated:completion: method of the currently active view controller, passing your configured image picker controller as the new view controller. On iPad, present the user interface using a popover. Doing so is valid only if the sourceType property of the image picker controller is set to UIImagePickerControllerSourceTypeCamera. To use a popover controller, use the methods described in “Presenting and Dismissing the Popover” in UIPopoverController Class Reference.
  5. When the user taps a button to pick a newly-captured or saved image or movie, or cancels the operation, dismiss the image picker using your delegate object. For newly-captured media, your delegate can then save it to the Camera Roll on the device. For previously-saved media, your delegate can then use the image data according to the purpose of your app.

    For details on these steps, refer to Apple's “Taking Pictures and Movies”.

4123 questions
27
votes
7 answers

How to know if iPhone camera is ready to take picture?

When [camera takePicture] is called before the camera is ready, it spits out this message: UIImagePickerController: ignoring request to take picture; camera is not yet ready. How can I know when it is ready to take a photo? [camera…
James Skidmore
  • 49,340
  • 32
  • 108
  • 136
26
votes
3 answers

iOS 7 UIImagePicker preview black screen

When i try to load camera from my code, camera preview is black. If I wait for 10-20 seconds it will show real camera preview. I found several questions and some of them suggest that running some other code in background should be the reason for…
user2689024
  • 261
  • 3
  • 5
26
votes
5 answers

How to avoid compression after selecting video from UIImagePickerController in ios

I am using UIImagePickerController to select video from Gallery and it compress that video.I want to disable Compression but I don't find the way to do this. I also tried with ELCImagePickerController it is showing video but it is looking like an…
DeviPhone26
  • 615
  • 2
  • 10
  • 16
26
votes
4 answers

iPad iOS7 - UIImagePickerController in UIPopoverController has wrong preview image

I am using an UIImagePickerController within an UIPopoverController which is working perfectly with iOS6. With iOS 7 the "preview" image which is shown to capture the image is rotated, but if I take a picture it is saved correctly. This is how I get…
25
votes
5 answers

UIImagePickerController thumbnail of video which is pick up from library

I am trying to get the thumbnail of the video which is pick up from library using the UIImagePickerController. Here is my code. I can get the the thumbnail of video if I using the camera to record a video. But I can not get the thumbnail if I pick…
Gargamal
  • 283
  • 1
  • 4
  • 7
25
votes
9 answers

How can i get the name of image picked through photo library in iphone?

I am picking an image from photo library in iphone application. How will i retrieve the actual image name. in .h class UIImageView * imageView; UIButton * choosePhotoBtn; in .m class -(IBAction) getPhoto:(id) sender { UIImagePickerController…
Sandeep Singh
  • 826
  • 2
  • 10
  • 24
25
votes
4 answers

UIImagePickerController bug

I think I found a bug in latest iOS 7 by running an app with Base SDK set to iOS 6.1 (possibly even lower versions too, haven't tested that out yet) I have this image in my photo library: https://i.stack.imgur.com/x2g1T.jpg I present a…
0xSina
  • 20,973
  • 34
  • 136
  • 253
24
votes
2 answers

How can I tell if the image returned from didFinishPickingMediaWithInfo was from the camera or the photoalbum?

I have a view controller that needs to be able to choose a picture from the photo album and also from the camera. I can only have 1 delegate method for didFinishPickingMediaWithInfo and while I can tell if it's an image, I can't seem to tell if it's…
pizzafilms
  • 3,829
  • 4
  • 24
  • 39
24
votes
5 answers

Save Photos to Custom Album in iPhones Photo Library

I'm trying to create a custom album in the Photo Library of an iPhone and then save photos that I've taken with the camera, or chosen from the phones Camera Roll to that custom album. I can successfully create the album but the photos are not…
23
votes
2 answers

What's the library should I import for UTTypeImage, which is the replacement of kUTTypeImage in iOS 15?

Before iOS 15, I used UIImagePickerController to capture images and video, and I got mediaType from [UIImagePickerController.InfoKey : Any], then I used kUTTypeImage (in the MobileCoreServices library) to identify the mediaType. However, When it…
manman
  • 1,268
  • 11
  • 14
23
votes
13 answers

didFinishPickingMediaWithInfo not called

I have a UITableViewCell button to take an image and place it back in the cell. When I call the UIImagePickerController and take the image, it doesn't call the following delegate: func imagePickerController(picker: UIImagePickerController,…
Tal Zion
  • 6,308
  • 3
  • 50
  • 73
23
votes
9 answers

UIImagePickerController in Landscape

I have been searching for an answer to this, but cannot come up with anything. Apparently, iPhone SDK 3.0 made it possible that UIImagePickerController can be displayed in landscape mode - but I am not finding any method that will allow this. I…
23
votes
3 answers

ios 7 image picker inside popover wrong behavior

My image picker view controller setted inside popover controller. On iOS 6 everything works great, but on iOS 7 the image is rotated and all movings are doing verse: when turning iPad left image is going down, when moving up image going left,…
aparesidam
  • 309
  • 2
  • 13
22
votes
6 answers

iPhone :How to get duration of video selected from library?

I am using UIImagePickerController to choose video file from library. And user can upload the video. Also I am using videoMaximumDuration property while user wants to capture video and upload it. I want to know that How can I get the duration…
Maulik
  • 19,348
  • 14
  • 82
  • 137
22
votes
3 answers

Image size taken from Flutter Image_Picker plugin is way too big

I want to use auto-focus on the camera, which is available on the image_picker plugin. However, when I call: var bytes = new File(imagePath); var enc = await bytes.readAsBytes(); print(enc.length); I got: 5121126 which takes at least 10 seconds…
Dai Dao
  • 327
  • 1
  • 2
  • 8