WebView is Blank

I am making a project using Xamarin.Mac. For some reason the Webview is not loading. I tried checking the code on a real mac project and it worked fine. Here is the code I am using:

webBrowser1.MainFrame.LoadRequest( new NSUrlRequest(new NSUrl("https://www.google.com")));

Please help me with this.

Thanks

Posts

  • MikeCodesDotNetMikeCodesDotNet GBXamarin Team Xamurai

    Hi,

    You should be able to do something like the following:

    webView.MainFrameUrl = "http://www.xamarin.com/";

    I hope this helps.

  • MohamadYaghmourMohamadYaghmour LBMember

    Hey,

    I already tried that before and it is still blank..

  • MohamadYaghmourMohamadYaghmour LBMember

    Also for some reason in the XCode .xib file. I am getting this error.
    "Unknown name type WebView"

  • MikeCodesDotNetMikeCodesDotNet GBXamarin Team Xamurai

    I've gone ahead and put together a sample App that demonstrates this working for you.

    You can download it here:
    https://www.dropbox.com/s/nkgzd60r1cj7aau/WebViewSample.zip

    If the above doesn't compile and run for you, could you let me know what version of our tools you have installed? To get this, please do the following:

    Xamarin Studio > About Xamarin Studio > Show Details > Copy Information

    All the best,
    Mike

  • MohamadYaghmourMohamadYaghmour LBMember

    Thanks a lot Michael. I tried something else in the same project. I inserted another WebView to the main window of the application and it works fine. The problem I am facing is when I am opening the window as a dialog.

                using(var modalWindowCtl = new TwitterPinController()) {
                    modalWindowCtl.validationUrl = "http://google.com";
                    NSApplication.SharedApplication.RunModalForWindow(modalWindowCtl.Window);
                    modalWindowCtl.Close();
                }
    

    And in TwitterPinController.cs on a button click action I am calling this function

                this.mywebview.FinishedLoad += delegate {
                    String was_redirected_to_url = mywebview.MainFrameUrl.ToString ();
                    Console.WriteLine ("in OnFinishedLoad, landed at: " + was_redirected_to_url);
                };
                this.mywebview.MainFrameUrl = validationUrl;
    

    What made me think that the problem is from the modal window is that when I am closing that window the FinishedLoad function is returning.

    What could be the problem causing this ?

  • MohamadYaghmourMohamadYaghmour LBMember

    Anyone ?

Sign In or Register to comment.