Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIImagePickerController's cameraOverlayView is offset after taking photo

When you implement a cameraOverlayView for a UIImagePickerController, this view appears while you're taking the photo and after the photo has been taken, providing you with an opportunity to cancel or retake the photo. The problem I'm seeing is if your cameraOverlayView is on top of the photo preview area, when you take the photo and it shows you the preview, the photo you took doesn't align with the cameraOverlayView anymore. The entire photo preview pane has been moved down ~50 points while the cameraOverlayView has stayed in place. This is a problem when you need the photo to be aligned perfectly with the view.

How can this be adjusted so the two are perfectly aligned - while taking the photo and after it has been taken?

Notice how the whole preview area is pushed down after taking the photo.

enter image description here

like image 409
Jordan H Avatar asked Feb 06 '15 19:02

Jordan H


1 Answers

I had a similar problem and came up with the following workaround:

if (IPhone5 || IPhone5c || IPhone5s)
{
     imagePicker.cameraViewTransform = CGAffineTransformTranslate(imagePicker.cameraViewTransform, 0, 30);
}
else if (IPhone6 || IPhone6Plus)
{
     imagePicker.cameraViewTransform = CGAffineTransformTranslate(imagePicker.cameraViewTransform, 0, 44);
}

This ensures that the picture that was taken will have approximately the same center as the camera preview layer (in portrait orientation).

like image 76
Florin Pop Avatar answered Sep 23 '22 12:09

Florin Pop