gpt4 book ai didi

ios - Iphone 6 和 6+ 中带有自定义覆盖的 imagePicker 预览模式全屏

转载 作者:行者123 更新时间:2023-11-29 12:31:53 25 4
gpt4 key购买 nike

目前我正在为自定义相机使用 UIImagePicker View。我使用以下方法修复了 Iphone 5 中的 Perview 模式。我不必为 Iphone 6 和 6+ 提供支持。我是否应该通过编码为每个屏幕调整变换比例。

[[NSBundle mainBundle] loadNibNamed:@"overlayView" owner:self options:nil];
self.overlayView.frame = self.imagePickerController.cameraOverlayView.frame;
self.imagePickerController.cameraOverlayView = self.overlayView;
self.overlayView = nil;

//For iphone 5+
//Camera is 426 * 320. Screen height is 568. Multiply by 1.333 in 5 inch to fill vertical
CGAffineTransform translate = CGAffineTransformMakeTranslation(0.0, 71.0); //This slots the preview exactly in the middle of the screen by moving it down 71 points
self.imagePickerController.cameraViewTransform = translate;

CGAffineTransform scale = CGAffineTransformScale(translate, 1.333333, 1.333333);
self.imagePickerController.cameraViewTransform = scale;

最佳答案

在这里输入图片描述

CGSize screenSize = [[UIScreen mainScreen] bounds].size;
// set the aspect ratio of the camera
float heightRatio = 4.0f / 3.0f;
// calculate the height of the camera based on the screen width
float cameraHeight = screenSize.width * heightRatio;
// calculate the ratio that the camera height needs to be scaled by
float scale = screenSize.height / cameraHeight;
// move the controller to the center of the screen
self.imagePickerController.cameraViewTransform = CGAffineTransformMakeTranslation(0, (screenSize.height - cameraHeight) / 2.0);
// concatenate the scale transform
self.imagePickerController.cameraViewTransform = CGAffineTransformScale(self.imagePickerController.cameraViewTransform, scale, scale);

但由于这个原因,我也得到了在预览模式下未显示的相同额外区域。我以前遇到过同样的错误,但面积较小。我怎样才能只捕获可见的区域。

关于ios - Iphone 6 和 6+ 中带有自定义覆盖的 imagePicker 预览模式全屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27470323/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com