当按下后退按钮时,WebView会崩溃应用程序,Xamarin.forms,android

问题描述 投票:0回答:1

我的应用程序崩溃按下后退按钮。我有产品布局,所有内容都已加载,产品描述为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

c# android xamarin.forms
1个回答
0
投票

CustomRenderer文件中存在问题:

await System.Threading.Tasks.Task.Delay(100); // wait here till content is rendered 
wv.HeightRequest = (double)webView.ScrollView.ContentSize.Height;

第一行应删除,不应该等待。

© www.soinside.com 2019 - 2024. All rights reserved.