未调用UIWebView委托方法LoadFinished

时间:2017-07-18 11:17:45

标签: c# ios xamarin.ios uiwebview

我正在Web视图中加载一个网页,视图正确加载但未调用LoadFinished委托方法,所有其他委托方法都被正确调用。这是我的代码

public partial class TestViewController
{
    public TestViewController(){}
    public override void ViewDidLoad()
    {
        base.ViewDidLoad();

        MyWebViewDelegate webDelegate = new MyWebViewDelegate();
        myWebView.Delegate = webDelegate;

        string webUrl = "https://www.google.co.in/"
        if (Connectivity.CheckForInternetConnection() && webUrl != null)
        {
            myWebView.LoadRequest(new NSUrlRequest(new NSUrl(webUrl)));
            ProgressView.Show();
        }
        else
        {
            ProgressView.Hide();
        }
        myWebView.ScalesPageToFit = true;
    }
}

public class MyWebViewDelegate : UIWebViewDelegate
{
    public MyWebViewDelegate() : base(){}

    public override void LoadFailed(UIWebView webView, NSError error)
    {
        ProgressView.Hide();
    }

    public override bool ShouldStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType)
    {
        return true;
    }

    public override void LoadingFinished(UIWebView webView)
    {
        ProgressView.Hide();
    }
}

我需要检测加载完成,隐藏进度视图,但我不知道我的代码有什么问题请帮助我。在此先感谢

0 个答案:

没有答案