UIImagePickerController cameraViewTransform在iOS 10中不起作用 [英] UIImagePickerController cameraViewTransform is not working in iOS 10

查看:121
本文介绍了UIImagePickerController cameraViewTransform在iOS 10中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的应用程序中实现了相机叠加视图.相机重叠视图在iOS 9中可以正常工作,但是iOS 10 cameraViewTransform无法解决该问题.请指导我.谢谢

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

我的工作代码

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);

更新

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];

推荐答案

iOS 10.2修复了此问题!现在,您可以在再次展示相机之前使用cameraViewTransform属性.

iOS 10.2 fixes this issue! You can now use the cameraViewTransform property before presenting the camera again.

这篇关于UIImagePickerController cameraViewTransform在iOS 10中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆