我的应用程序崩溃按下后退按钮。我有产品布局,所有内容都已加载,产品描述为html格式,所以我使用的是WebView。当我进入产品并快速点击后退按钮时,应用程序崩溃并显示错误“无法访问已处置的对象,Android.Webkit.WebView”。
var fullDesc = new ProductPageWebView() { HeightRequest = 20 };
fullDesc.Margin = -8;
var htmlSource = new HtmlWebViewSource();
htmlSource.Html = product.FullDescription;
fullDesc.Source = htmlSource;
overviewContent.Children.Add(fullDesc);
innerGrid.Children.Add(overviewContent, 0, 3, 7, 8);
我评论过fullDesc.Source = htmlSource;什么都没有崩溃,所以存在问题。怎么解决?它只在android上崩溃。它是xamarin app .net标准2.0
ProductPageWebView继承自WebView
CustomRenderer文件中存在问题:
await System.Threading.Tasks.Task.Delay(100); // wait here till content is rendered
wv.HeightRequest = (double)webView.ScrollView.ContentSize.Height;
第一行应删除,不应该等待。