3

I am working on a iOS app using Xamarin iOS and I have a webView that loads local html, However the webView takes up the entire screen so there is no place to put a back button.

here's my load localhtml code:

using CoreGraphics;
using Foundation;
using System;
using System.CodeDom.Compiler;
using System.IO;
using UIKit;

namespace AppName
{
    partial class View : UIViewController{


        public View(IntPtr handle) : base(handle)
        {
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Perform any additional setup after loading the view, typically from a nib.
            var webView = new UIWebView(new CGRect(0, 20, View.Frame.Width, View.Frame.Height -20));
            View.AddSubview(webView);



            // Method 2 using LoadRequest
            string fileName = "Content/local.html"; // remember case-sensitive
            string localHtmlUrl = Path.Combine(NSBundle.MainBundle.BundlePath, fileName);
            webView.LoadRequest(new NSUrlRequest(new NSUrl(localHtmlUrl, false)));
            webView.ScalesPageToFit = false;
        }

        public override void DidReceiveMemoryWarning()
        {
            base.DidReceiveMemoryWarning();
            // Release any cached data, images, etc that aren't in use.
        }
    }
}

what am I doing wrong?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Phoneswapshop
  • 1,367
  • 8
  • 24
  • 47

1 Answers1

0
var webView = new UIWebView(new CGRect(0, 20, View.Frame.Width, View.Frame.Height -20));

You're setting the frame of the web view to the full frame of your controller's frame (except for the y position, which you're setting to 20 px from top).

I think you should read UIView frame, bounds and center.

Community
  • 1
  • 1
asp_net
  • 3,567
  • 3
  • 31
  • 58