Question

I am creating a mobile app that will load a webpage in one of its screens, but for some reason the webpage always resizes itself out of the webview bound. Please see below screenshots and advise. I am not sure what I did wrong since I am very new in mobile app development. I tried to google for similar problems and wasnt able to find anything similar, so I apologize in advanced if this is a repeating question. Below is a copy of my ViewDidLoad.

public override void ViewDidLoad ()
    {
        base.ViewDidLoad ();
        webViewGoogle = new UIWebView (View.Bounds);
        View.AddSubviews (webViewGoogle);

        string url = "http://google.com";
        webViewGoogle.LoadRequest (new NSUrlRequest (new NSUrl(url)));
        webViewGoogle.ScalesPageToFit = true;
    }

Below is a screenshot of my design. I only want to put the website INSIDE the UIWebView box, but it resizes to cover the full screen..(second screenshot) Please help! edit: fixed the issue by changing viewDidLoad() with the following:

 public override void ViewDidLoad ()
 {
    string url = "http://google.com";
    webViewGoogle.LoadRequest (new NSUrlRequest (new NSUrl(url)));
    webViewGoogle.ScalesPageToFit = true;
 }

Taking out the subView did the trick!

No correct solution

OTHER TIPS

This line

webViewGoogle = new UIWebView (View.Bounds);

tells iOS to make the webview as big as the bounds of the view that contains it. If you want the webview to be smaller, specify a smaller frame when you instantiate it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top