Xamarin.ios中未调用ShouldStartLoad

时间:2019-07-17 12:02:32

标签: ios xamarin xamarin.ios uiwebview

我有一个列表,如果我选择任何项目,它会导航到另一个名为testCotroller的控制器,在这里viewdidload方法中我正在设置我的自定义委托,在此我定义了ShouldstartLoad。 第一次加载url时,应该会调用shouldstartload,但是当单击链接或按钮重定向到另一个url时,应该不会调用那个时间。startstartload是我的代码

//控制器

public override void ViewDidLoad()
    {
        base.ViewDidLoad();


        this.Title = "Dashboard";

        testDelegate testDelegate = new testDelegate(this);
        this.WebView.Delegate = (UIWebViewDelegate)webViewDelegate;

//its already initialized
this.testViewModel.PropertyChanged += this.testViewModel_PropertyChanged;
    }
private void testViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
    {
this.WebView.LoadRequest(url);
}


//Delegate
internal class testDelegate: UIWebViewDelegate
{
    UIViewController currentInstance;

    public testDelegate( UIViewController currentInstance)
    {

        currentInstance = this.currentInstance;
    }

    public override void LoadFailed(UIWebView webView, NSError error)
    {

    }

    public override void LoadingFinished(UIWebView webView)
    {

        return;
    }

    public override bool ShouldStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType)
    {
     //doing some work

        return true;
    }

当我单击webview中的链接/按钮时,应该会调用startload。

0 个答案:

没有答案