Ejemplo n.º 1
0
        void SetupControl(FormsWebView element)
        {
            WebViewControlDelegate.OnNavigationRequestedFromUser += OnUserNavigationRequested;
            WebViewControlDelegate.OnInjectJavascriptRequest     += OnInjectJavascriptRequested;
            WebViewControlDelegate.OnStackNavigationRequested    += OnStackNavigationRequested;
            WebViewControlDelegate.OnActionAdded += OnActionAdded;

            UserController = new WKUserContentController();
            UserController.AddScriptMessageHandler(this, "invokeAction");

            NavigationDelegate   = new FormsWKNavigationDelegate(this, element);
            WebViewConfiguration = new WKWebViewConfiguration {
                UserContentController = UserController
            };

            var webView = new WKWebView(Frame, WebViewConfiguration);

            webView.Opaque             = false;
            webView.UIDelegate         = this;
            webView.NavigationDelegate = NavigationDelegate;
            webView.ScalesPageToFit    = true;

            OnControlChanging?.Invoke(this, Element, Control);
            SetNativeControl(webView);
            OnControlChanged?.Invoke(this, Element, Control);
        }
        private void SetupControl(FormsWebView element)
        {
            WebViewControlDelegate.OnNavigationRequestedFromUser += OnUserNavigationRequested;
            WebViewControlDelegate.OnInjectJavascriptRequest     += OnInjectJavascriptRequested;
            WebViewControlDelegate.OnActionAdded += OnActionAdded;

            UserController = new WKUserContentController();
            UserController.AddScriptMessageHandler(this, "invokeAction");

            NavigationDelegate   = new FormsWKNavigationDelegate(this, element);
            WebViewConfiguration = new WKWebViewConfiguration {
                UserContentController = UserController
            };

            var webView = new WKWebView(Frame, WebViewConfiguration);

            webView.UIDelegate         = this;
            webView.NavigationDelegate = NavigationDelegate;

            UriBase = NSBundle.MainBundle.ResourcePath;

            OnControlChanging?.Invoke(this, Element, Control);
            SetNativeControl(webView);
            OnControlChanged?.Invoke(this, Element, Control);
        }