iPad iOS7 - Uiimagepickercontroller in Uipopovercontroller Has Wrong Preview Image

iPad iOS7 - UIImagePickerController in UIPopoverController has wrong preview image

The UIImagePickerController has a property called cameraViewTransform. Applying a CGAffineTransform to this will transform the preview image but will not transform the captured image which will therefore be correctly captured. I have the same problem that you describe and I solved it (for iOS7) by creating my camera controller and placing it in a popover as follows:

UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];

[imagePickerController setDelegate:self];

imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;

CGFloat scaleFactor=1.3f;

switch ([UIApplication sharedApplication].statusBarOrientation) {

case UIInterfaceOrientationLandscapeLeft:

imagePickerController.cameraViewTransform = CGAffineTransformScale(CGAffineTransformMakeRotation(M_PI * 90 / 180.0), scaleFactor, scaleFactor);

break;

case UIInterfaceOrientationLandscapeRight:

imagePickerController.cameraViewTransform = CGAffineTransformScale(CGAffineTransformMakeRotation(M_PI * -90 / 180.0), scaleFactor, scaleFactor);

break;

case UIInterfaceOrientationPortraitUpsideDown:

imagePickerController.cameraViewTransform = CGAffineTransformMakeRotation(M_PI * 180 / 180.0);

break;

default:
break;
}

__popoverController = [[UIPopoverController alloc] initWithContentViewController:imagePickerController];

[__popoverController presentPopoverFromRect:presentationRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

I also scale the image when in Landscape so that it fills the viewfinder more than it otherwise would. To my mind this is all rather nasty, but I will hopefully be able to remove it once iOS7.1 arrives.

ios 7 image picker inside popover wrong behavior

As the Apple's Official Doc said:

Present the user interface. On iPhone or iPod touch, do this modally (full-screen) 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, the correct way to present an image picker depend on its source type, as summarized in this table:

  • Camera Photo: Use full screen
  • Library Saved: Must use a popover
  • Photos Album: Must use a popover

...

On iPad, if you specify a source type of UIImagePickerControllerSourceTypeCamera, you can present the image picker modally (full-screen) or by using a popover. However, Apple recommends that you present the camera interface only full-screen.

Though it said "you can present the image picker modally (full-screen) or by using a popover", as you see by using a popover will result with this weird issue. I guess this might be a bug on iOS 7 SDK.

I'm still trying to fix this issue, but for now, the only way I can tell is to show it modally by

-presentViewController:animated:completion:

method, which is in full-screen (Actually, I don't like this way).

And there's a THREAD discussed about it on Apple's Dev Forums, you can take a look at it. ;)

ipad UIImagePickerController different size on preview and on take pic Landscape

I see 2 differences in your sample images: size and a horizontal flip.

The size difference could be because you are setting picker.modalPresentationStyle = UIModalPresentationFullScreen; but then you are displaying it in a smaller popover.
I would try and present the picker without a popover and see if it works.

Also, the preview image looks a bit distorted. If you are using Scale To Fill as contentMode for the imageView then I would change it to Aspect Fill.

I don't know where the horizontal flip might come from.

iPad camera popover preview wrong rotation and scale

Turns out to be an issue with the way iOS 6.0 deals with rotation - its fixed in 6.1

UIImagePickerController via UIPopoverController

As another option, you could use the popover's setContentViewController: or setContentViewController:animated: to change to the UIImagePickerController and then change back to your own view controller.

UIImagePickerController in UIPopoverController is showing as blank white view

Also you should specify UIImagePicker's sourceType.

_picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

UPDATE

Initialise picker this way:

_picker = [[UIImagePickerController alloc] init];


Related Topics



Leave a reply



Submit