UIImagePickerController Unable to select images issue? - ios

This is my code to present the UIImagePickerController:
UIImagePickerController *imagepicker = [[UIImagePickerController alloc] init];
imagepicker.delegate = self;
imagepicker.view.backgroundColor = [UIColor orangeColor];
UIImagePickerControllerSourceType sourcheType = UIImagePickerControllerSourceTypePhotoLibrary;
imagepicker.sourceType = sourcheType;
imagepicker.allowsEditing = YES;
[self presentViewController:imagepicker animated:YES completion:nil];
This is the image where the error occurred
This is a normal picture
This happens on one iPad (iOS 11.1.2), but it works fine on the other (iOS 8.4.1). I tried the changes, but none seemed to work.

Related

iOS 14 - Thumbnails do not display in the UIImagePickerController

Thumbnails do not display in the UIImagePickerController when running on iPhone 11 or real device with iOS 14.
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate=self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
[self presentViewController:picker animated:YES completion:nil];
Result:
Photos and Albums showing as Blank but when I tap on-screen image will be selected.
For me, it was caused by using
UIScrollView.appearance(whenContainedInInstancesOf: [UINavigationController.self]).backgroundColor = .backgroundPrimaryNew
I don't know why is that, but after I've removed this line it began working again and thumbnails are showing.
Try this
Instead of presenting add UIImagePickerController as subView
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate=self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
[self.view addSubview:self.picker.view];
[self addChildViewController:self.picker];
[self.picker didMoveToParentViewController:self];

UIImagepicker display Image capturing instead of Video recording

I am using UIImagepickerController to capture video in my app.
Sometimes it behaves strangely - that image capturing is coming. Mostly it comes when a new user is registered and try to capture a video or a new ipa file is installed and tested. Eventhough it appears randomly.
When I prompt UIImagepickerController it display take photo button (White button) instead of video record button (Red button)
Here is my code -
UIImagePickerController *imagePicker=[[UIImagePickerController alloc]init];
imagePicker.delegate=self;
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
imagePicker.allowsEditing = YES;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];
}
[self presentViewController:imagePicker animated:YES completion:NULL];
Just try replacing your code with this.
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
// picker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMoviekUTTypeImage];
picker.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeMovie,nil];
//picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:picker animated:YES completion:NULL];

UIImagePickerController doesn't display rotate button

It's an iPhone app running in iPad in iOS7. In iPhone it works fine.
However in iPad, the rotate button is not displayed and the view is like cut off on the top.
I'm not doing anything strange with the image picker. Here's how I show it:
- (void)showImagePickerWithSourceType:(UIImagePickerControllerSourceType)sourceType
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.mediaTypes = #[(NSString*)kUTTypeImage];
imagePicker.sourceType = sourceType;
imagePicker.delegate = self;
imagePicker.allowsEditing = YES;
//Select front facing camera if available
if (sourceType == UIImagePickerControllerSourceTypeCamera && [UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront])
{
imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
}
[self presentViewController:imagePicker animated:YES completion:nil];
}

iOS UIImagePickerController has white squares instead of icons

I am using the camera for my app but when i start it, the camera shows up like in the image below.
This is the code I use to start the camera app:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:picker animated:YES completion:NULL];
Why are the camera icons all white?

How to access photo library for ipad apps

I am facing a problem when I try to access the photo library when developing iPad apps. However, the same code works properly for iPhone dev. The error which is generated is:
On iPad, UIImagePickerController must be presented via UIPopoverController
I am using the following code for iPad development:
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
{
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
[picker release];
}
Try presenting with a pop over controller in iPad, doesn't support modal view controller
even I encountered the same problem, so tried using pop over controller and it works now :)
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
popControl = [[UIPopoverController alloc]initWithContentViewController:picker];
popControl.delegate=self;
[popControl presentPopoverFromRect:browseButton.bounds inView:mainView permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];

Resources