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
16
votes
17 answers

How to get file name in UIImagePickerController with Asset library?

I want to get the file name from UIImagePickerController. I do not want to use ALAssetLibrary because it is deprecated in iOS 9. I have used the following code but it always returns the image name as "Asset.jpg" for each file. func…
TechChain
  • 8,404
  • 29
  • 103
  • 228
16
votes
2 answers

UIImagePickerController does not work correct on ios 9.3 iPad 4

After update ipad to ios 9.3 images are stop to display. What can be wrong with it? On iOS 9 and iOS 9.2 that was work as well. On other devices iPhone devices all work fine. private func presentPickerForLibrary() { let imagePicker =…
Paul Lafytskyi
  • 273
  • 3
  • 12
16
votes
2 answers

Force UIImagePickerController to Crop a Square Image

How do we force UIIImagePickerController to crop a square image? I have searched all over and I haven't found a solid solution. Thankyo var imagePickerController: UIImagePickerController =…
JayVDiyk
  • 4,277
  • 22
  • 70
  • 135
15
votes
6 answers

iOS 5 GM: : More than maximum 5 filtered album lists trying to register. This will fail

I know this thread existed before, but was closed as only appearing in iOS5 beta 6. By now I have the Golden Master of iOS 5 on my phone and that error still appears. This is happening when I create a UIImagePickerController with a sourceType of…
Infinite
  • 2,931
  • 2
  • 27
  • 33
15
votes
4 answers

ipad camera and webview youtube video playing issue

Rootviewcontroller has a webview that plays a youtube video and it has one camera button. User can click on camera button and record video. up to this point its working fine When I dismiss the camera controller and try to play the video in…
GameLoading
  • 6,688
  • 2
  • 33
  • 57
15
votes
4 answers

How to retrieve PHAsset from UIImagePickerController

I'm trying to retrieve a PHAsset however PHAsset.fetchAssets(withALAssetURLs:options:) is deprecated from iOS 8 so how can I properly retrieve a PHAsset?
Peter Warbo
  • 11,136
  • 14
  • 98
  • 193
15
votes
4 answers

Is there a way to prevent UIImagePickerController change statusbar style?

UIImagePickerController changes statusbar style to black/opaque. I want to keep status-bar style black/translucent. I'm finding a way to prevent status bar style changing. Or making it transited smoothly. Now, presenting UIImagePickerController…
eonil
  • 83,476
  • 81
  • 317
  • 516
15
votes
4 answers

camera overlay view - just for preview?

I've noticed that in OS 3.1 you can add an overlay view to the image picker with cameraOverlayView However, I've also noticed that adding a view via this method also displays the view for the entire time the UIImagePicker is displayed, when I only…
mac_55
  • 4,130
  • 7
  • 31
  • 40
15
votes
9 answers

How to get the custom overlay for UIImagePicker camera to be full screen in iOS 7?

I am interested in using a custom overlay for the UIImagePickerController for camera controls that take the entire screen, very similar to what the default Camera app does when switched to the video function. I have referenced several questions…
daspianist
  • 5,336
  • 8
  • 50
  • 94
15
votes
3 answers

UIImagePickerController crash only on iOS 7 - iPad

I'm getting hundreds of crashes from one of my live apps ever since people started upgrading to iOS 7. Has anyone else seen this problem? Nothing reproduces on my iPad 3 with iOS 7... Link to Crashlytics: crashes.to/s/edf2e71d9a5 Fatal Exception…
jjxtra
  • 20,415
  • 16
  • 100
  • 140
15
votes
2 answers

iOS Custom UIImagePickerController Camera Crop to Square

I'm trying to create a camera like Instagram where the user can see a box and the image would crop to that box. For Some reason the camera doesn't go all the way to the bottom of the screen and cuts off near the end. I'm also wondering how would I…
14
votes
2 answers

App crashes when trying to obtain photos from photo library via Image picker

Anyone encountered this error before when trying to access the photo library using the image picker? NSInvalidArgumentException Cannot set metadata in read-only store. Any advise on what actually went wrong and suggestions on how I can resolve…
Zhen
  • 12,361
  • 38
  • 122
  • 199
14
votes
6 answers

Swift 4.2 imagePickerController issue

Trying to pass chat client from swift 4 to swift 4.2 and with picker i found trouble. UIImagePickerControllerEditedImage Cannot subscript a value of type '[String : Any]' with an index of type 'UIImagePickerController.InfoKey' func…
George Heints
  • 1,303
  • 3
  • 20
  • 37
14
votes
3 answers

UIImagePickerController not asking for permission

I have implemented the following code in an app to allow the user to add an image to the app. However the user is never asked for permission to access photo's. What am I missing here? in my info.plist I have set: Privacy - Photo Library Usage…
scottc00
  • 283
  • 1
  • 2
  • 8
14
votes
10 answers

UIImagePickerController delegate not called Swift 3

On the surface I thought that this had to be a delegate issue, but after asking for the delegate the right one was returned. I created an ImagePicker class to handle all the UIImagePickerController stuff. Every thing works until the delegate methods…
Clayton C.
  • 863
  • 1
  • 8
  • 17