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
348
votes
20 answers

iOS UIImagePickerController result image orientation after upload

I am testing my iPhone application on an iOS 3.1.3 iPhone. I am selecting/capturing an image using a UIImagePickerController: UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; [imagePicker…
james
  • 26,141
  • 19
  • 95
  • 113
312
votes
35 answers

Adding images or videos to iPhone Simulator

I am trying to use UIImagePickerController with UIImagePickerControllerSourceTypePhotoLibrary, but it says, "No photos". Where does the simulator get the images from? Where should I copy the images so that they are displayed in the simulator?
Vijayeta
  • 5,585
  • 5
  • 21
  • 11
230
votes
20 answers

iOS 8 Snapshotting a view that has not been rendered results in an empty snapshot

In iOS 8 I am having problem capturing images from camera till now I am using this code for UIImagePickerController *controller=[[UIImagePickerController alloc]…
souvickcse
  • 7,742
  • 5
  • 37
  • 64
220
votes
26 answers

Cropping an UIImage

I've got some code that resizes an image so I can get a scaled chunk of the center of the image - I use this to take a UIImage and return a small, square representation of an image, similar to what's seen in the album view of the Photos app. (I know…
159
votes
6 answers

Detect permission of camera in iOS

I am developing a very simple video app. I use the official control: UIImagePickerController. Here is the problem. When presenting the UIImagePickerController for the first time, the iOS will ask for the permission. The user can click yes or no. If…
user418751
  • 1,937
  • 2
  • 18
  • 21
141
votes
12 answers

Can I load a UIImage from a URL?

I have a URL for an image (got it from UIImagePickerController) but I no longer have the image in memory (the URL was saved from a previous run of the app). Can I reload the UIImage from the URL again? I see that UIImage has a…
progrmr
  • 75,956
  • 16
  • 112
  • 147
110
votes
20 answers

How to allow user to pick the image with Swift?

I am writing my first iOS application (iPhone only) with Swift. The main application view should allow user to choose the image from the photo gallery. I've found the following sample code of ViewController.swift: class ViewController:…
LA_
  • 19,823
  • 58
  • 172
  • 308
103
votes
16 answers

UIImagePickerController error: Snapshotting a view that has not been rendered results in an empty snapshot in iOS 7

I am getting this error only in iOS 7 and the application crashed. In iOS 6, I never get any error, just once of memory warning when opening the camera. Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view…
Didats Triadi
  • 1,502
  • 2
  • 14
  • 13
102
votes
5 answers

iOS 10 error [access] when using UIImagePickerController

I am using XCode 8 and testing with iOS 10.2 Beta. I have added the Photos, PhotosUI and MobileCoreServices frameworks to project. Very simple code: #import #import #import…
101
votes
5 answers

presentModalViewController:Animated is deprecated in ios6

I am using the following code for an image picker. But when I run it in the simulator, I have a memory leak and I get a warning about presentModalViewcontroller:animated being deprecated in iOS6. I also get dismissModalViewController:animated…
Ram
  • 1,687
  • 3
  • 18
  • 28
67
votes
9 answers

Front facing camera in UIImagePickerController

I am developing the front facing camera app in iPad2 by using the UIImagePickerController. When I capture the image it's shows as flipped from left to right. How do I correct this? if ([UIImagePickerController…
dineshprasanna
  • 1,284
  • 4
  • 20
  • 37
66
votes
8 answers

Cannot subscript a value of type '[String : Any]' with an index of type 'UIImagePickerController.InfoKey'

I'm using Apple's Swift iOS Tutorial. Which is throwing an error, Cannot subscript a value of type '[String : Any]' with an index of type 'UIImagePickerController.InfoKey' The function they defined is below. func imagePickerController(_ picker:…
drobati
  • 761
  • 1
  • 5
  • 4
63
votes
15 answers

UIImagePickerController doesn't fill screen

I'm adding a custom overlay to the UIImagePickerController and there is a persistant black bar at the bottom of the view. Here is my code to instantiate the controller. - (UIImagePickerController *)imagePicker { if (_imagePicker) { …
kubi
  • 48,104
  • 19
  • 94
  • 118
56
votes
12 answers

UIImagePickerController not presenting in iOS 8

Is anyone else having an issue with UIImagePickerController in iOS 8? The method below works perfectly well in iOS 7 on an iPad, but I get the following error when I run this in XCode 6 (Beta 3 or 4) when I try to present the picker (last line). …
Dave
  • 2,409
  • 3
  • 22
  • 28
56
votes
18 answers

UIImagePickerController and extracting EXIF data from existing photos

It's well known that UIImagePickerController doesn't return the metadata of the photo after selection. However, a couple of apps in the app store (Mobile Fotos, PixelPipe) seem to be able to read the original files and the EXIF data stored within…
tomtaylor
  • 2,309
  • 1
  • 22
  • 36
1
2 3
99 100