配置 UIImagePickerController 的帧大小 [英] configuring frame size of UIImagePickerController

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

问题描述

是否可以更改 UIImagePickerController 的可显示帧大小?我想显示相机视图,但不是在整个屏幕上,而是在 100x100 的边界框中显示.

Is it possible to change the displayable frame size of UIImagePickerController? I want to display camera view but not on the entire screen, but say in a 100x100 bounding box.

这是我的 viewDidAppear:

Here is my viewDidAppear:

- (void) viewDidAppear:(BOOL)animated {

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls = NO;
picker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
picker.cameraViewTransform = CGAffineTransformScale(picker.cameraViewTransform, CAMERA_TRANSFORM_X, CAMERA_TRANSFORM_Y);

[self presentModalViewController:picker animated:YES];  

[super viewDidAppear:YES];
 }

我在任何地方都找不到这样做的方法...没有人使用它吗?

I could not find a way to do that anywhere...doesnt anyone using it?

推荐答案

我尝试了我上一篇文章中的代码,并注释掉了最终的缩放变换((使其变为全尺寸的那个),我最终得到了一个可爱的微型相机 imagePicker 漂浮在我的屏幕中间,所以它确实有效!我使用的确切代码,包括缩放/淡入过渡,是 -

I experimented with the code from my last post, and commented out the final scale transform ((the one which makes it full size) and I ended up with a lovely miniature camera imagePicker floating in the middle of my screen, so it definitely does work! The exact code I used, including the zoom/fade-in transition, is -

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

imagePickerController.delegate = self;
imagePickerController.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeImage, nil];
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;

UIView *controllerView = imagePickerController.view;

controllerView.alpha = 0.0;
controllerView.transform = CGAffineTransformMakeScale(0.5, 0.5);

[[[[UIApplication sharedApplication] delegate] window] addSubview:controllerView];

[UIView animateWithDuration:0.3
                  delay:0.0
                options:UIViewAnimationOptionCurveLinear
             animations:^{
                 controllerView.alpha = 1.0;
             }
             completion:nil
 ];

[imagePickerController release];

我相信您可以对其进行更多自定义,更改大小和相机视图的位置.

I'm sure you could customise it more, change the size & location of the camera view.

这篇关于配置 UIImagePickerController 的帧大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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