我只是使用迁移工具将我的Xamarin iOS应用程序迁移到Xamarin Unified。下面的代码工作正常,应用程序在迁移之前没有任何错误或警告。迁移后我得到以下错误Error-1 PresentViewController不接受MediaPickerController对象作为参数。 Error-2 mediaPickerController没有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);
}
}
答案 0 :(得分:0)
您需要将包含MediaPickerController的Xamarin组件更新为与Xamarin.iOS统一代码兼容的最新版本!
Xamarin.Mobile的最新版本是0.7.6。如果您使用较旧的项目,请仔细检查您的项目。