简体   繁体   中英

Errors Message after migration to unified API

I just migrate my Xamarin iOS app to Xamarin Unified using the Migration Tool. The code below was working fine and the app didn't have any error or warning before the migration. After the migration I got the following errors Error-1 PresentViewController doesn't accept the MediaPickerController object as a parameter. Error-2 mediaPickerController doesn't have the method DismissViewController

        protected void TakePicture()
{
    MediaPickerController mediaPickerController = mediaPicker.GetTakePhotoUI(new StoreCameraMediaOptions
    {
        Name =  this.PictureName + ".jpg",
        DefaultCamera = CameraDevice.Rear
    });
    if (!mediaPicker.IsCameraAvailable)
    {
        ShowUnsupported();
    }

//Error-1
    PresentViewController(mediaPickerController, true, null);
    try
    {
        mediaPickerController.GetResultAsync().ContinueWith(t =>
        {
            BTProgressHUD.Show("Processing");
            // Dismiss the UI yourself

//Error-2
            mediaPickerController.DismissViewController(true, () =>
            {
                if (t.IsCanceled || t.IsFaulted)
                {
                    BTProgressHUD.Dismiss();
                    return;
                }
                MediaFile file = t.Result;
                FinishedPickingMedia(file);
                BTProgressHUD.Dismiss();
            });



       }, TaskScheduler.FromCurrentSynchronizationContext());
    }
    catch (Exception ex)
    {
        Insights.Report(ex, ReportSeverity.Error);
    }
}

You need to update your Xamarin component that contains MediaPickerController to the latest version compatible with Xamarin.iOS unified code!

The latest version of Xamarin.Mobile is 0.7.6. Double check with your project if your are using an older one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM