来自摄像头的ios7 CameraPickerController图像被冻结

时间:2013-10-10 07:48:32

标签: ios xamarin.ios uiimagepickercontroller xamarin

我有相机View控制器的简单代码:

UIImagePickerController picker = new UIImagePickerController();
picker.PrefersStatusBarHidden ();
picker.SourceType = UIImagePickerControllerSourceType.Camera;
UIImagePickerControllerCameraDevice dev = picker.CameraDevice;
PresentViewController (picker, false, null);
picker.FinishedPickingMedia += (object sender, UIImagePickerMediaPickedEventArgs e) => BeginInvokeOnMainThread (delegate {DismissViewController (false, null);});

当应用程序启动时,我可以正常捕捉照片,但是当我再次出现选择器时,会出现相机视图,但会显示并冻结上一次拍摄的帧(图像)。如果我移动我的设备图像不会改变。换句话说,我可以使用相机一次,但我不能使用它两次。我做错了什么?在iOS6设备上,它可以完美运行。

1 个答案:

答案 0 :(得分:4)

制作一个pickerDelegate类为我做了诀窍。您只需在构造函数中传递当前VC,以便可以在VC中处理图像。

<强> PickerDelegate

private class pickerDelegate : UIImagePickerControllerDelegate
        {
            private yourVC _vc;

            public pickerDelegate (yourVC controller) : base ()
            {
                _vc = controller;
            }

            public override void FinishedPickingImage (UIImagePickerController picker, UIImage image, NSDictionary editingInfo)
            {
               //Do something whit the image
                _vc.someButton.SetBackgroundImage (image, UIControlState.Normal);

                //Dismiss the pickerVC
                picker.DismissViewController (true, null);
            }
        }

<强> viewDidLoad中

imagePicker = new UIImagePickerController ();

//Set the Delegate and pass the current VC
imagePicker.Delegate = new pickerDelegate (this);