本文介绍了UIImagePickerController cameraViewTransform在iOS 4中的行为不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我将我的iPhone和SDK升级到iOS 4.0.1,现在我的应用程序运行方式与在iOS 3.x中运行方式不同。 我的应用程序使用UIImagePickerController与自定义cameraOverlayView(我会在这篇文章中禁止)。主要的是,我需要看到iphone相机在全屏模式。 我使用XCode模板项目创建了一个基于视图的应用程序,名为CameraTransform ,所以我有两个类: CameraTransformAppDelegate 和 CameraTransformViewController ,确定!在 CameraTransformViewController 的 viewDidAppear 方法中,我输入以下代码: - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; UIImagePickerController * picker = [[UIImagePickerController alloc] init]; picker.sourceType = UIImagePickerControllerSourceTypeCamera; picker.delegate = self; // [self configurePicker_FirstAttempt:picker];用这个! // [self configurePicker_SecondAttempt:picker];使用这个! [self presentModalViewController:picker animated:YES]; } - (void)configurePicker_FirstAttempt:(UIImagePickerController *)picker { picker.showsCameraControls = NO; picker.navigationBarHidden = YES; //不需要(使用默认值) //picker.toolbarHidden = YES; //picker.wantsFullScreenLayout = YES; } - (void)configurePicker_SecondAttempt:(UIImagePickerController *)picker { //转换全屏支持的值 CGFloat cameraTransformX = 1.0; CGFloat cameraTransformY = 1.12412; picker.cameraViewTransform = CGAffineTransformScale(picker.cameraViewTransform,cameraTransformX,cameraTransformY); } 使用/ i运行项目: 两个 configurePicker_FirstAttempt 和 configurePicker_SecondAttempt 方法调用已注释: defaultPicker.png 。 只有 configurePicker_SecondAttempt 方法调用已注释: configurePicker_FirstAttempt.png 。 两个 configurePicker_FirstAttempt 和 configurePicker_SecondAttempt 方法调用取消注释: configurePicker_SecondAttempt.png 。 注意: 在iOS 3.x中,我使用第三种方法(两种方法取消注释)来配置选择器, 我检查了 picker.cameraViewTransform 原始值(缩放前),并设置 picker.view.frame 设置为屏幕边界的(0.0,0.0,320.0, 480.0) 我尝试将翻译连接到 picker.cameraViewTransform (缩放后),如下所示: CGAffineTransformTranslate(picker.cameraViewTransform,0.0,20.0); ,我意识到有一部分相机视图被隐藏(也许它的原点不是0.0,0.0)所以我在屏幕上获得了更多的摄像头视图。 看起来像在新的SDK UIImagePickerController已经改变了某种方式,也许 有没有人有这个问题?解决方案 That is the relationship cameraresolution-screenresolutionFor 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中的行为不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!