我有相机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
设备上,它可以完美运行。
答案 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);