Camera view finder comes up black on iPad - ios

I have an iPhone app that presents a UIImagePickerController for users to take a photo. It works fine on iPhone, iPod and an iPad mini, but on one iPad 3 it comes up like this.
Can anyone think of a reason this would happen? There's nothing blocking the lens, and all other camera apps work fine on the device.
I'm presenting the controller like this:
self.picker = [[UIImagePickerController alloc] init];
self.picker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeImage];
self.picker.delegate = self;
self.picker.toolbarHidden = YES;
self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
self.picker.allowsEditing = NO;
self.picker.showsCameraControls = YES;
if ([UIImagePickerController isFlashAvailableForCameraDevice:UIImagePickerControllerCameraDeviceRear])
{
self.picker.cameraFlashMode = UIImagePickerControllerCameraFlashModeAuto;
}
[self presentModalViewController:picker animated:YES];
I would really appreciate any help
Thanks

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];

UIImagePickerController Unable to select images issue?

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.

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];
}

iPad camera popover preview wrong rotation and scale

I am showing the camera in a popover (on an iPad - the iPad app is locked to Lanscape Left) and the preview is in Portrait and the wrong scale. The code is below - I have worked out the rotation and added it, but the preview size is the too thin now.
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.videoQuality = UIImagePickerControllerQualityTypeMedium;
imagePicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
CGAffineTransform transformRotation = CGAffineTransformMakeRotation(270 * M_PI/180);
imagePicker.cameraViewTransform = transformRotation;
}
else
{
NSLog(#"Camera not available. Using photo library");
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
imagePicker.delegate = self;
_photoPopover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
[_photoPopover presentPopoverFromRect:view.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
Turns out to be an issue with the way iOS 6.0 deals with rotation - its fixed in 6.1
I think this is the solution for ur question so u can follow the code as per this link provided below.
UIImagePickerController in Landscape
It will helps u a lot.Enjoy the coding.

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