iOS6 on iPad UIImagePickerController issue - ios

My app uses UIImagePickerContoller and it works fine with iOS 7 (iPad and iPhone) but only works on the iPhone with iOS 6. On the iPad with iOS 6 it crashes in the simulator when I click on the button that uses this class to select a picture from the photo library, but does not indicate why in the debugger log. My app is restricted to portrait view. The code is below:
-(IBAction)selectPicturePressed:(id)sender
{
//Open a UIImagePickerController to select the picture
UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
imgPicker.delegate = self;
imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self.navigationController presentViewController:imgPicker animated:YES completion:nil];
}

UIImagePickerController must be presented in a UIPopoverController when the source type is the photo library.

Related

Default flash controls of camera app appears truncated

We are developing and iOS application and in one of the View Controllers UIImagePickerController is used to present the camera to the user. In the view controller there is a UIButton and in the event listener method we have the following code.
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
imagePicker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff;
[self presentViewController:imagePicker animated:YES completion:NULL];
Camera app is presented properly, but the flash control titles are appearing truncated (Auto is appearing as Au..., Off is appearing as ...) as shown in the screen shots. It would be great if someone can help out. I'm guessing it's some app configuration issue, as the same code works in a different project.
Thanks in advance.

Issue with UIImagePickerController library source

When I open the UIImagePickerControllerSourceTypePhotoLibrary, the frame of the editing view is not in alignment with the picture. Here is my code:
UIImagePickerController * picker = [[UIImagePickerController alloc] init] ;
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.allowsEditing=YES;
[self presentViewController:picker animated:YES completion:^{}];
Here is a screenshot showing the problem:
As you can see, the top part of the editing view frame is above the actual image. Any help is appreciated.
EDIT: This issue only occurs with the iPhone 6 and 6+. Works fine with iPhone 5s.

How to access iOS simulator camera [duplicate]

This question already has answers here:
How do I test a camera in the iPhone simulator?
(7 answers)
Closed 8 years ago.
I am making a camera app. I need to test the app in the simulator but I can't access the iOS simulator camera.
If not possible in the simulator means I need to access my system camera. Whether it is possible?
I tried UIImagePickerController but it doesn't work.
The below the code I've tried.
self.imagePicker = [[UIImagePickerController alloc] init];
UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
self.usingPopover = YES;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
sourceType = UIImagePickerControllerSourceTypeCamera;
self.usingPopover = NO;
}
[self.imagePicker setSourceType:sourceType];
self.imagePicker.allowsEditing = NO;
self.imagePicker.delegate = self;
if (sourceType != UIImagePickerControllerSourceTypeCamera) {
self.popover = [[UIPopoverController alloc] initWithContentViewController:self.imagePicker];
self.popover.delegate = self;
[self.popover presentPopoverFromRect:popoverFrame inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
} else {
[self presentModalViewController:imagePicker animated:YES];
}
It's not possible to access the camera of your development machine to be used as the simulator camera. Camera functionality is not available in any iOS version and in any Simulator. You will have to use a real device for camera testing purposes.
Simulator doesn't have a Camera. If you want to access a camera you need a device. You can't test camera on simulator. You can only check the photo and video gallery.

Front-facing / rear-facing camera button not showing in UIImagePickerController on iPad 2 iOS 7

I have an iPhone-only app. It allows users to capture videos using the default UIImagePickerController.
When you run the app on an iPad 2 running iOS 7, the UIImagePickerController does not show the "swap camera" button in the upper right-hand corner. This is the button that allows the user to switch between the front-facing and rear-facing cameras. I have no idea why the button is not there. The button is there on iPhone and on iPad 3. The problem only happens on iPad 2. See attached screenshot.
Weird behavior - if you rotate the iPad to landscape mode, and tap where the button is supposed to be, it actually switches to the front facing camera. So the functionality is there, but for some reason the button is not visible.
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
picker.allowsEditing = YES;
picker.videoMaximumDuration = 1800;
picker.videoQuality = UIImagePickerControllerQualityTypeMedium;
[self.navigationController presentViewController:picker animated:YES completion:nil];
[picker release];
Image here:
http://i.imgur.com/1IAeMU0.png
The UIImagePickerController only works on portrait, so you have to make a workaround to handle the orientation switch, like subclassing the UIImagePickerController, and changing the view when the orientation changes.
Credits: https://stackoverflow.com/a/21484101/736384

iPad2 camera display not showing

I have an iPhone app that displays the camera using UIImagePicker to take a picture. I am porting it to iPad2 and when i want to display the camera (through a modalviewcontroller) i get the camera buttons but the display in the preview is just white. If i take the picture i can see it.
Does this happen to you?
I am experiencing the same problem. I moved the UIImagePicker code to my rootviewcontroller, and it worked. I could see what was actually through the viewfinder. It also worked via a popover in the existing viewcontroller (called next after the rootviewcontroller), but the resolution was poor when I displayed the photo. This is not satisfactory, but I guess I found a workaround if absolutely necessary.
Yesterday only i have tried this code to use camera to take pics. from my app and it worked on iphone after porting it.
I think you need to call takePicture method on the controller.
Just a guess.
if([UIImagePickerController isSourceTypeAvailable:sourceType])
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = sourceType;
picker.delegate = self;
if(sourceType == UIImagePickerControllerSourceTypeCamera)
[picker takePicture];
[self presentModalViewController:picker animated:YES];
[picker release];
}

Resources