UIImagePickerController cameraViewTransform doesn't scale on iOS 10 beta 7

I have been using below code to scale my UIImagePickerController's live preview to fill the entire screen (because aspect ratio of camera preview and main screen are different). This worked perfectly till now.


CGSize screenSize = [[UIScreen mainScreen] bounds].size; 
float screenHeight= MAX(screenSize.height, screenSize.width); 
float screenWidth= MIN(screenSize.height, screenSize.width); 
float cameraAspectRatio = 4.0 / 3.0; 
float imageWidth = floorf(screenWidth * cameraAspectRatio); 
float scale = ceilf((screenHeight / imageWidth) * 10.0) / 10.0; 
objImagePickerController.cameraViewTransform = CGAffineTransformMakeTranslation(0, (screenHeight - imageWidth) / 2.0); 
objImagePickerController.cameraViewTransform= CGAffineTransformMakeScale(scale, scale);


I installed iOS 10 beta 7 on an iPhone 5 and it doesn't scale. I can see black patch at the bottom of UIImagePickerController's view. Seems like

CGAffineTransformMakeScale
isn't working properly here.


Did anybody else face this issue? This is short of weird behavior appearing in iOS 10 beta OS. I am unable to find a workaround for this. Please advise.

NOTE:: objImagePickerController is an instance of UIImagePickerController.

Replies

The same bug persists in beta 8 as well. Very frustrating from Apple.

For me, this is still broken in the iOS 10.0.1 GM (14A403).

Also still broken for me... Whats upsetting is i dont know if i should look at trying to fix it (in so much as changing the behind view) or if they will fix it. I opened a radar over a week ago about it.

I face this issue as well ... hope that they will fix it asap !

I found a workaround. If you wait until the AVCaptureSessionDidStartRunningNotification notification, then set cameraViewTransform, the transform is applied.


1. Observe the notification


    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(cameraIsReadyNotification:) name:AVCaptureSessionDidStartRunningNotification object:nil];


2. In the notification handler:


- (void)cameraIsReadyNotification:(NSNotification *)notification
{
  dispatch_async(dispatch_get_main_queue(), ^{
    self.cameraViewTransform = CGAffineTransformMakeTranslation(100,  100); // or whatever
  });
}


I filed a radar for the discrepancy between iOS 9 and 10: 28235716

Hi peymano2,

Thanks for this workaround .... but this solve part of my problem ... because once the picture is taken with [picker takePicture]... a short display of it appear whitout any translation .... any idea to fix it ?

Thanks in advance for your help ! OldNick

Hey peymano2,


Thanks for the suggestion ! it works , but as soon as you rotate the phone the view turns back to the non transformed one, any ideas? Thanks!

hlp pls opening my home screen

Still this camera transform is not working in public iOS 10.0.2 Release. Any other good fix for the camera transform in UIImagePickerController?

Over the latest betas of IOs 10, it seems that Apple does not intend to fix this issue ... so - Apple - please fix it asap !

It works on first time appearence but it breaks when you change the camera source to Library and then back to Camera.

Good news !!! The 10.2 beta version has fixed the issue ... cameraViewTransform is now working perfectly (at least in my code) !

I had this exact problem that affecte a white lable app with over 160 corporate clients 😟


I have also confirmed that my issue is solved by installing 10.2 beta.


Can't wait till the public version is released.

Can confirm cameraViewTransform has been fixed, at least in 10.2 public beta 2