ios7 CameraPickerController image from camera is frozen

旧时模样 提交于 2020-01-01 12:06:07

问题


I have this simple code for camera View controller:

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);});

When app starts, I can capture photo normally, but when i present picker again, camera View appears but frame(image) from previous shot is shown and frozen. If i move my device around image doesn't change. In other words, I can use camera once but I can not use it twice. What I am doing wrong? On iOS6 devices it works perfectly.


回答1:


Making a pickerDelegate class did the trick for me. You just have to pass the current VC in the constructor so you can handle the image in your 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);


来源:https://stackoverflow.com/questions/19289955/ios7-camerapickercontroller-image-from-camera-is-frozen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!