【问题标题】:Xamarin Forms WebView won't Refresh/Reload after first load?Xamarin Forms WebView 首次加载后不会刷新/重新加载?
【发布时间】:2016-07-25 05:53:34
【问题描述】:

我对 xamarin 完全陌生。 我正在尝试在更改后让 Web 视图在 IOS 上刷新。 (以下代码在 IOS 模拟器上工作,但不在真实设备上工作,将显示兑现版本 - 以下代码中的 IP 地址是本地 Web 服务器,如果我在安装后更改网站中的任何内容,它不会反映更改)。

请帮忙。我做错了什么?

干杯

.xaml ->

<!--<controls:HybridWebView x:Name="hybridWebView">
        </controls:HybridWebView>-->
<WebView x:Name="webView"
VerticalOptions="FillAndExpand"
Source="http://192.168.1.130" />
<StackLayout Orientation="Horizontal"
  BindingContext="{x:Reference webView}">

  <Button Text="&#x21D0;"
  FontSize="Large"
  HorizontalOptions="FillAndExpand"
  Clicked="OnGoBackClicked" />

  <Button Text="&#x21D2;"
  FontSize="Large"
  HorizontalOptions="FillAndExpand"
  Clicked="OnGoForwardClicked" />
</StackLayout>

.xaml.cs ->

public WebPage()
    {
        InitializeComponent();

    }
    void OnEntryCompleted(object sender, EventArgs args)
    {
        //hybridWebView.Source = ((Entry)sender).Text;
    }
    void OnGoBackClicked(object sender, EventArgs args)
    {
        webView.Source="http://192.168.1.130";
    }
    void OnGoForwardClicked(object sender, EventArgs args)
    {
        webView.Source = "https://www.google.com";

    }

【问题讨论】:

    标签: xaml xamarin xamarin.forms


    【解决方案1】:

    在设置源之前,您需要找到它。只需在您的按钮单击中尝试此操作

     var vewbView = this.FindByName<WebView>("yourView");
            vewbView.Source =
                "http://stackoverflow.com/questions/38538970/xamarin-forms-webview-wont-refresh-reload-after-first-load#new-answer";
    

    【讨论】:

      猜你喜欢
      • 2015-06-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多