简体   繁体   English

在iOS上以Xamarin形式预加载WebView

[英]Preload WebView in Xamarin Forms on iOS

I have a WebView in a ContentPage that I am instantiating and setting the url to the WebView in the constructor. 我在ContentPage中有一个WebView,我正在实例化并将URL设置为构造函数中的WebView。 I am then later showing this ContentPage with PushModalAsync. 然后,我稍后将使用PushModalAsync显示此ContentPage。 Thing is, the WebView doesn't seem to be attempting to load until I do the Push. 事实是,在执行Push之前,WebView似乎没有尝试加载。 Is there a way to have it preload in the background instead of waiting until it is shown? 有没有办法让它在后台预加载而不是等到它显示出来?

You can fetch content using HttpClient and then Load WebView with html data 您可以使用HttpClient获取内容,然后使用html数据加载WebView

WebView.Source =  new HtmlWebViewSource() { BaseUrl = urlPreloaded, Html = httpClientData}

In this way, the html data will be pre-loaded. 这样,html数据将被预加载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM