Beispiel #1
0
        public Xamarin.Forms.View CreateWebView()
        {
            var preferences = new WKPreferences()
            {
                JavaScriptEnabled = true,
                JavaScriptCanOpenWindowsAutomatically = false
            };
            var configuration = new WKWebViewConfiguration()
            {
                UserContentController = userContentController = new WKUserContentController()
            };
            var helper         = new Ao3TrackHelper(this);
            var messageHandler = new Ao3TrackReader.iOS.ScriptMessageHandler(helper);

            userContentController.AddScriptMessageHandler((WKScriptMessageHandler)messageHandler, "ao3track");
            this.helper = helper;

            configuration.Preferences = preferences;

            webView = new WKWebView(configuration)
            {
                NavigationDelegate = new NavigationDelegate(this)
            };

            webView.FocuseChanged += WebView_FocusChange;

            var xview = webView.ToView();

            xview.SizeChanged += Xview_SizeChanged;

            return(xview);
        }