i have implemented camera overlay view in my application. camera overlay view working good in iOS 9. but iOS 10 cameraViewTransform not working how to resolve this problem. please guide me. Thanks
my working code
CGSize screenBounds = [UIScreen mainScreen].bounds.size;
CGFloat cameraAspectRatio = 4.0f/3.0f;
CGFloat camViewHeight = screenBounds.width * cameraAspectRatio;
CGFloat scale = screenBounds.height / camViewHeight;
picker.cameraViewTransform = CGAffineTransformMakeTranslation(0, (screenBounds.height - camViewHeight) / 2.0);
picker.cameraViewTransform = CGAffineTransformScale(picker.cameraViewTransform, scale, scale);
update
OverlayView *overlay = [[OverlayView alloc]
initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
picker =
[[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls = NO;
picker.navigationBarHidden = NO;
picker.toolbarHidden = YES;
// Device's screen size (ignoring rotation intentionally):
CGSize screenSize = [[UIScreen mainScreen] bounds].size;
float cameraAspectRatio = 4.0 / 3.0;
float imageWidth = floorf(screenSize.width * cameraAspectRatio);
float scale = ceilf((screenSize.height / imageWidth) * 10.0) / 10.0;
picker.cameraViewTransform = CGAffineTransformScale(CGAffineTransformIdentity, 2, 2);
picker.cameraOverlayView = overlay;
picker.allowsEditing = NO;
UIPinchGestureRecognizer *pinchRec = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(zoom:)];
[overlay addGestureRecognizer:pinchRec];
overlay.image =image;
[self.navigationController presentViewController:picker animated:NO completion:nil];
Try this:
I had the same problem earlier in IOS 9.3 also. Here is the code i used
Hope this helps. For more help: UIImagePickerController's cameraViewTransform is ignoring 'scaling' and 'translation' on iOS 10 beta
iOS 10.2 fixes this issue! You can now use the
cameraViewTransform
property before presenting the camera again.