[英]How to detect active window of multiple instances when back button pressed in Xamarin.Forms WebView OnBackButtonPressed
[英]WebView crashes app when back button is pressed, Xamarin.forms, android
按下后退按鈕時,我的應用程序崩潰。 我有產品布局,其中所有內容都已加載,並帶有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 Standard 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;
第一行應該刪除,它不應該等待。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.