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

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

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

码:

public override void ViewDidLoad ()
    {
        base.ViewDidLoad ();

        // Perform any additional setup after loading the view,typically from a nib.           

        PictureFromCameraButton.TouchUpInside += PictureFromCameraButton_Click;

    }

private void PictureFromCameraButton_Click (object sender,EventArgs e)
    {
        try {
            Thread.Sleep (4000);                
                ImagePickerController.SetSourceType(UIImagePickerControllerSourceType.Camera);
    this.PresentViewController (ImagePickerController,true,null);


        } catch (NotSupportedException exception) {
            //Logging Exception in Flurry
            FA.Flurry.LogError(exception.GetType().Name,exception.Message,new NSError(NSError.CocoaErrorDomain,3584));

            BeginInvokeOnMainThread (() => {
                UIAlertView ErrorAlert = new UIAlertView ("Device unsupported","Your device does not support this feature",new UIAlertViewDelegate (),"OK");
                ErrorAlert.Show ();
            });
        } catch (Exception ex) {
            //Logging Exception in Flurry
            FA.Flurry.LogError(ex.GetType().Name,ex.Message,3584));
            this.ShowErrorInProcessingAlertView ();
        }
    }

解决方法

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

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

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

[self presentViewController:imagePickerController animated:YES completion:^{....}];
原文链接:https://www.f2er.com/iOS/331278.html

猜你在找的iOS相关文章