How to use UIImagePickerController in iPad?

UIImagePickerController must be presented with UIPopoverController on iPad. if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker]; [popover presentPopoverFromRect:self.selectedImageView.bounds inView:self.selectedImageView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; self.popOver = popover; } else { [self presentModalViewController:picker animated:YES]; } EDIT: Add a strong property for the UIPopoverController: @property (nonatomic, strong) UIPopoverController *popOver; The popover should be dismissed in … Read more

How to get file name in UIImagePickerController with Asset library?

import Photos Before iOS 11 func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { if let imageURL = info[UIImagePickerControllerReferenceURL] as? URL { let result = PHAsset.fetchAssets(withALAssetURLs: [imageURL], options: nil) let assetResources = PHAssetResource.assetResources(for: result.firstObject!) print(assetResources.first!.originalFilename) } dismiss(animated: true, completion: nil) } After iOS 11 func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { … Read more

iPhone SDK – How to disable the picture preview in UIImagePickerController?

I asked a similar question here My solution was to create a customized view on top of the default UIImagePickerControllerView. I downloaded the example Augmented Reality Then you can use the OverlayView.m and OverlayView.h by adding them to your project: I made the custom picker toolbar, picker and overlayView global so that I can access … Read more

Swift – How to record video in MP4 format with UIImagePickerController?

I made some modifications to the following 2 answers to make it compatible with Swift 5: https://stackoverflow.com/a/40354948/2470084 https://stackoverflow.com/a/39329155/2470084 import AVFoundation func encodeVideo(videoURL: URL){ let avAsset = AVURLAsset(url: videoURL) let startDate = Date() let exportSession = AVAssetExportSession(asset: avAsset, presetName: AVAssetExportPresetPassthrough) let docDir = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] let myDocPath = NSURL(fileURLWithPath: docDir).appendingPathComponent(“temp.mp4”)?.absoluteString let docDir2 = FileManager.default.urls(for: .documentDirectory, … Read more

iPhone, “More than maximum 5 filtered album lists trying to register. This will fail.” Error

I think you are not checking the source type. You might be doing self.sourceType =UIImagePickerControllerSourceTypePhotoLibrary; If this is the case, then you have to check the source type before assigning it directly. like if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypePhotoLibrary]) { // Set source to the Photo Library self.sourceType =UIImagePickerControllerSourceTypePhotoLibrary; } I hope it helps

Presenting a modal view controller immediately after dismissing another

Aug 2012 Update: iOS 5 and greater have introduced safer APIs for doing things after modals have animated into / out of place using completion blocks: [self presentViewController:myModalVC animated:YES completion:^{}]; [self dismissViewControllerAnimated:YES completion:^{}]; Pre-Aug 2012 Answer: I encountered a similar problem when dismissing modal one and then presenting modal two in rapid succession. Sometimes modal … Read more

How to open the ImagePicker in SwiftUI?

You need to wrap UIImagePickerController in a struct implementing UIViewControllerRepresentable. For more about UIViewControllerRepresentable, please check this amazing WWDC 2019 talk: Integrating SwiftUI struct ImagePicker: UIViewControllerRepresentable { @Environment(\.presentationMode) private var presentationMode let sourceType: UIImagePickerController.SourceType let onImagePicked: (UIImage) -> Void final class Coordinator: NSObject, UINavigationControllerDelegate, UIImagePickerControllerDelegate { @Binding private var presentationMode: PresentationMode private let sourceType: UIImagePickerController.SourceType … Read more