ePickerController如何做从后置摄像头到前置摄像头

ePickerController如何做从后置摄像头到前置摄像头

本文介绍了UIImagePickerController如何做从后置摄像头到前置摄像头的动画切换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在为 UIImagePickerController 控制器使用自定义叠加层,并且一切正常。我添加了按钮,可通过-

I have been using custom overlay for UIImagePickerController controller, and everything is working fine. I have added button to switch between front and rear camera via -

 - (IBAction)changeCamera:(id)sender {
if (self.imagePicker.cameraDevice == UIImagePickerControllerCameraDeviceRear) {
    self.imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
}
else {
    self.imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
}
}

问题是,开关没有动画。我一直在使用建立在UIImagePicker之上的Apple相机应用,并且该开关正处于动画状态。我该怎么做?

Problem is, switch is not animated. I have been using apple camera app which is built on top of UIImagePicker, and the switch is happening animated. How do I do this?

推荐答案

我今天尝试这样做,并且能够在以下环境中使用它代码:

I was trying to do this today, and I was able to get it working with the following code:

[UIView transitionWithView:imagePickerController.view duration:1.0 options:UIViewAnimationOptionAllowAnimatedContent | UIViewAnimationOptionTransitionFlipFromLeft animations:^{
            imagePickerController.cameraDevice = UIImagePickerControllerCameraDeviceRear;
        } completion:NULL];

我希望这对遇到此问题的人有所帮助。

I hope this helps anyone who comes across this question.

这篇关于UIImagePickerController如何做从后置摄像头到前置摄像头的动画切换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 17:32