UIImagePickerController cameraViewTransform 在 iOS 4 中的行为不同 [英] UIImagePickerController cameraViewTransform acts differently in iOS 4

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

问题描述

我将我的 iPhone 和 SDK 都升级到了 iOS 4.0.1,现在我的应用程序的运行方式与在 iOS 3.x 中的运行方式不同.

I upgraded both my iPhone and SDK to iOS 4.0.1 and now my App doesn't run the same way it was running in iOS 3.x.

我的应用程序使用 UIImagePickerController 和自定义 cameraOverlayView(我将在这篇文章中取消).重点是我需要在全屏模式下查看 iphone 相机.为了直接解决问题,我将放一些代码和屏幕截图来解释发生了什么.

My App uses the UIImagePickerController with a custom cameraOverlayView (which I'll suppress in this post). The main point is that I need to see the iphone camera in fullscreen mode. To go straight to the problem, I'll put some code and screenshots to explain what's happening.

我使用名为CameraTransform"的 XCode 模板项目创建了一个基于视图的应用程序,因此我得到了两个类:CameraTransformAppDelegateCameraTransformViewController,好的!在 CameraTransformViewControllerviewDidAppear 方法中,我输入了以下代码:

I created a View-Based Application using the XCode Template projects named "CameraTransform", so I got two classes: CameraTransformAppDelegate and CameraTransformViewController, ok! In the CameraTransformViewController's viewDidAppear method I put the following code:

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];

    UIImagePickerController* picker = [[UIImagePickerController alloc] init];

    picker.sourceType = UIImagePickerControllerSourceTypeCamera;        
    picker.delegate = self;

    //[self configurePicker_FirstAttempt:picker];   Use this!
    //[self configurePicker_SecondAttempt:picker];  Use this too!

    [self presentModalViewController:picker animated:YES];
}

- (void)configurePicker_FirstAttempt:(UIImagePickerController*) picker {
    picker.showsCameraControls = NO;
    picker.navigationBarHidden = YES;

    // not needed (use defaults)
    //picker.toolbarHidden = YES;
    //picker.wantsFullScreenLayout = YES;
}

- (void)configurePicker_SecondAttempt:(UIImagePickerController*) picker {

    // Transform values for full screen support
    CGFloat cameraTransformX = 1.0;
    CGFloat cameraTransformY = 1.12412;

    picker.cameraViewTransform = CGAffineTransformScale(picker.cameraViewTransform, cameraTransformX, cameraTransformY);
}

用/我得到的运行项目:

Running the project with/i got:

  • both configurePicker_FirstAttempt and configurePicker_SecondAttempt method calls commented: defaultPicker.png.
  • only configurePicker_SecondAttempt method call commented: configurePicker_FirstAttempt.png.
  • both configurePicker_FirstAttempt and configurePicker_SecondAttempt method calls uncommented: configurePicker_SecondAttempt.png.

注意:

  1. 在 iOS 3.x 中,我使用第三种方法(两种方法都未注释)来配置选择器,它以全屏模式显示,底部没有黑条".
  2. 我检查了 picker.cameraViewTransform 原始值(在缩放之前)并将其设置为 Identity(如预期的那样).
  3. picker.view.frame 设置为屏幕边界的 (0.0, 0.0, 320.0, 480.0)
  4. 我尝试将翻译连接到 picker.cameraViewTransform(在缩放后),如下所示:CGAffineTransformTranslate(picker.cameraViewTransform, 0.0, 20.0);意识到相机视图"的某些部分被隐藏了(可能它的原点不是 0.0、0.0),所以我在屏幕上看到了更多相机视图".
  1. In iOS 3.x I used the third approach (both methods uncommented) to configure the picker, which was show in the fullscreen mode without the "black bar" at the bottom.
  2. I inspected the picker.cameraViewTransform original value (before being scaled) and it is set to Identity (as expected).
  3. The picker.view.frame is set to the screen bounds's (0.0, 0.0, 320.0, 480.0)
  4. I tried to concatenate a translation to the picker.cameraViewTransform (after being scaled), like this: CGAffineTransformTranslate(picker.cameraViewTransform, 0.0, 20.0); and I realized that there was some part of the "camera view" that was hidden (maybe it's origin wasn't the 0.0, 0.0), so I got more "camera view" on screen.

看起来在新的 SDK 中 UIImagePickerController 发生了一些变化,也许相机控件的大小不同,或者类似.

It looks like in the new SDK the UIImagePickerController has changed in some way, maybe the camera controls have different sizes os something alike.

有人遇到过这个问题吗?

Has anyone had this problem?

推荐答案

ios 4.0 幻数 1936/320= 6.05 , 2592/6.05 = 428 , 480-428 = 52 52/(428/2)=0.24299 +1=1.24299

ios 4.0 Magic number 1936/320= 6.05 , 2592/6.05 = 428 , 480-428 = 52 52/(428/2)=0.24299 +1=1.24299

ios 3.0 幻数 1536/320=4.8 2048/4.8=427 480-427=53 53/427=0.121412 +1=1.12412

ios 3.0 Magic number 1536/320=4.8 2048/4.8=427 480-427=53 53/427=0.121412 +1=1.12412

这就是cameraresolution-screenresolution的关系

That is the relationship cameraresolution-screenresolution

对于 iOS 3.0,cameraViewTransform 是从顶部应用的,因此您必须使用所有高度.但是在 iOS4 中,它是从框架的中心应用的,所以你必须使用一半的高度.而且您必须将框架向下移动 (52/2) 以使框架保持在中间.

For iOS 3.0 the cameraViewTransform is applied from the top so you have to use all the height. But in iOS4 it is applied from the center of the frame so you have to use the half of the height. And you have to move the frame down (52/2) to leave the frame in the center.

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

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