我在iOS手机上遇到了这个问题。
https://github.com/jamesmontemagno/MediaPlugin/issues/433?_pjax=%23js-repo-pjax-container
这是导航到照片页面的代码。你可以看到我尝试的所有不同的东西
private async void addPhotosClickedAsync(object sender, EventArgs args)
{
// await ((RootPage)Application.Current.MainPage).Detail.Navigation.PushAsync(new TakePhoto(_workOrderId));
// await ((RootPage)App.Current.MainPage).Detail.Navigation.PushModalAsync(new TakePhoto(_workOrderId));
//Device.BeginInvokeOnMainThread(async () =>
//{
// await Navigation.PushAsync(new TakePhoto(_workOrderId));
//});
await ((RootPage)App.Current.MainPage).Detail.Navigation.PushAsync(new TakePhoto(_workOrderId));
}
在相机页面上,有一个相机按钮图标,可调用媒体插件拍摄照片。当图片UI返回时,它将图像源设置为刚刚拍摄的照片。 UI返回片刻,然后突然应用程序弹回根
private async Task OnCameraTapped(object sender, EventArgs args)
{
CameraHelper cameraHelper = new CameraHelper();
try
{
ImgBytes = await cameraHelper.TakePicture();
PhotoImage.Source = ImageSource.FromStream(() =>
{
return new MemoryStream(ImgBytes);
});
}
catch (Exception ex)
{
if (ex.Message == "No camera available")
{
await DisplayAlert("Error", "No camera available", "Ok");
}
else
{
await DisplayAlert("Error", "Unable to take picture.", "Ok");
}
}
}
对此有什么解决方法吗?