2

我必须在我的应用程序中的小屏幕区域中打开相机,但不知道如何实现它,因为相机会以全屏方式打开。 在此处输入图像描述

相机应该在uiimage视图区域中打开,请指导我如何实现这一点。谢谢。

4

2 回答 2

3

您应该看一下Apple 提供的AVCam示例项目。它具有您完成任务所需的所有功能。祝你好运!

于 2013-10-03T06:29:38.680 回答
2

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

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

你可以在这里查看我的答案。

于 2013-10-03T06:28:35.830 回答