快照未呈现的视图会导致xamarin.ios7中出现空快照

前端之家收集整理的这篇文章主要介绍了快照未呈现的视图会导致xamarin.ios7中出现空快照前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
什么时候,我从相机捕获图像,然后它在ios7的控制台上给出错误.我首先尝试没有在代码添加Thread.sleep(3000),但这也无法正常工作.

完整错误
快照未呈现的视图会导致空快照.确保在屏幕更新后快照或快照之前,您的视图至少呈现过一次.

码:

  1. public override void ViewDidLoad ()
  2. {
  3. base.ViewDidLoad ();
  4.  
  5. // Perform any additional setup after loading the view,typically from a nib.
  6.  
  7. PictureFromCameraButton.TouchUpInside += PictureFromCameraButton_Click;
  8.  
  9. }
  10.  
  11. private void PictureFromCameraButton_Click (object sender,EventArgs e)
  12. {
  13. try {
  14. Thread.Sleep (4000);
  15. ImagePickerController.SetSourceType(UIImagePickerControllerSourceType.Camera);
  16. this.PresentViewController (ImagePickerController,true,null);
  17.  
  18.  
  19. } catch (NotSupportedException exception) {
  20. //Logging Exception in Flurry
  21. FA.Flurry.LogError(exception.GetType().Name,exception.Message,new NSError(NSError.CocoaErrorDomain,3584));
  22.  
  23. BeginInvokeOnMainThread (() => {
  24. UIAlertView ErrorAlert = new UIAlertView ("Device unsupported","Your device does not support this feature",new UIAlertViewDelegate (),"OK");
  25. ErrorAlert.Show ();
  26. });
  27. } catch (Exception ex) {
  28. //Logging Exception in Flurry
  29. FA.Flurry.LogError(ex.GetType().Name,ex.Message,3584));
  30. this.ShowErrorInProcessingAlertView ();
  31. }
  32. }

解决方法

要在iOS 7中解决此问题,这就解决了我的同样错误.

当我呈现UIImagePickerController时,在我的情况下称为imagePickerController

不要使用nil或NULL.相反,我使用下面的代码,打开相机时不再出现错误.

  1. [self presentViewController:imagePickerController animated:YES completion:^{....}];

猜你在找的iOS相关文章