Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Snapshotting a view that has not been rendered results in an empty snapshot in xamarin.ios7

When,I am capturing image from camera then it is giving error on console in ios7.I tried firstly without adding Thread.sleep(3000) in code but that was also not working.

complete error: Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates.

code:

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,
                               new NSError(NSError.CocoaErrorDomain,3584));
            this.ShowErrorInProcessingAlertView ();
        }
    }
like image 560
Mahesh Bansode Avatar asked Jan 20 '14 15:01

Mahesh Bansode


1 Answers

To fix this problem in iOS 7, this is what solved my same error.

When I present the UIImagePickerController which in my case is called imagePickerController

Do not use nil or NULL. Instead, I used the below code and the error no longer appears when opening the camera.

[self presentViewController:imagePickerController animated:YES completion:^{....}];
like image 65
user3629281 Avatar answered Nov 09 '22 14:11

user3629281