public override void ViewDidLoad() { base.ViewDidLoad(); var webView = new WKWebView(new CGRect(), new WKWebViewConfiguration()); webView.TranslatesAutoresizingMaskIntoConstraints = false; View.Add(webView); webView.LoadFileUrl(_url, _url); }
public override void ViewDidAppear(bool animated) { if (_hasAppeared) { return; } var fileUrl = new NSUrl(NSBundle.MainBundle.PathForResource("index", "html"), false); _hasAppeared = true; _webView.Hidden = true; _webView.NavigationDelegate = this; _webView.UIDelegate = this; _webView.LoadFileUrl(fileUrl, fileUrl); View.AddSubview(_webView); }
public override void ViewDidLoad() { System.Console.WriteLine("=========================== ViewDidLoad"); base.ViewDidLoad(); var set = this.CreateBindingSet <W2WebView, W2WebViewModel>(); /* * set.Bind(Label).To(vm => vm.Hello); * set.Bind(TextField).To(vm => vm.Hello); */ set.Apply(); Web = new WKWebView(View.Bounds, new WKWebViewConfiguration()); Web.NavigationDelegate = new NavigationDelegate(this); Add(Web); /* * var loadableViewModel = ViewModel as LoadableViewModel; * if (loadableViewModel != null) * { * loadableViewModel.Bind(x => x.IsLoading).Subscribe(x => * { * if (x) NetworkActivity.PushNetworkActive(); * else NetworkActivity.PopNetworkActive(); * }); * }*/ //var url = "https://coltrack.com/index.jsp"; // NOTE: https required for iOS 9 ATS //Web.LoadRequest (new NSUrlRequest (new NSUrl (url))); //Web.LoadHtmlString("html/index.html", new NSUrl(NSBundle.MainBundle.BundlePath) ); string contentDirectoryPath = Path.Combine(NSBundle.MainBundle.BundlePath, "Content/"); //var html = "<html><h1>Hello</h1><p>World</p></html>"; var html = @" <html> <head> <title>Xamarin Forms</title> <meta charset='utf-8' /> <!-- <link href='styles.css' rel='stylesheet'> --> </head> <body> <h1>Xamarin.Forms</h1> <p>Привет мир</p> <!-- <img src='image2.png' /> --> </body> </html>"; //Web.LoadHtmlString(html, NSBundle.MainBundle.BundleUrl); //Web.LoadHtmlString("html/index.html", new NSUrl(Const.ContentDirectory, true) ); string index = Path.Combine(NSBundle.MainBundle.BundlePath, "html/menu4.html"); string webAppFolder = Path.Combine(NSBundle.MainBundle.BundlePath, "html"); Web.LoadFileUrl(new NSUrl("file://" + index), new NSUrl("file://" + webAppFolder)); }