public WKWebViewController(ExtendedBrowserOptions options, CancellationToken cancellationToken)
        {
            _options = options;

            var webViewConfig = new WKWebViewConfiguration();

            webViewConfig.WebsiteDataStore = WKWebsiteDataStore.NonPersistentDataStore;
            //webViewConfig.SetUrlSchemeHandler(new CallbackHandler(), endUrl.Scheme);
            WebView = new WKWebView(new CGRect(0, 0, 0, 0), webViewConfig);

            WebView.WeakNavigationDelegate = this;

            // Setup cancellation action
            cancellationToken.Register(() => UIApplication.SharedApplication.InvokeOnMainThread(() => ActivityMediator.Instance.Cancel()));

            var request = new NSMutableUrlRequest(new NSUrl(options.LoadDetourUrl ? options.DetourUrl : options.StartUrl));

            if (_options.Headers != null)
            {
                var updatedRequest = UpdateHeaders(new NSMutableUrlRequest(new NSUrl(options.LoadDetourUrl ? options.DetourUrl : options.StartUrl)),
                                                   _options.Headers.ToDictionary(k => k.Key.ToString(), v => v.Value.ToString()));
                if (updatedRequest != null)
                {
                    WebView.LoadRequest(updatedRequest);
                    return;
                }
            }
            WebView.LoadRequest(request);
        }
示例#2
0
        public static WebViewWrapper WrapperFactory(MusicProvider provider)
        {
            WKUserContentController controller = new WKUserContentController();

            controller.AddUserScript(
                new WKUserScript(new NSString(provider.EventsJs), WKUserScriptInjectionTime.AtDocumentEnd, false)
                );
            controller.AddScriptMessageHandler(Container.WKScriptMessageHandler, "playbackState");

            WKWebViewConfiguration config = new WKWebViewConfiguration
            {
                UserContentController = controller
            };

            config.Preferences.SetValueForKey(NSObject.FromObject(true), new NSString("developerExtrasEnabled"));

            var webView = new WKWebView(new CGRect(0, 0, 100, 100), config)
            {
                CustomUserAgent = "Mozilla/5.0 " +
                                  "(Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 " +
                                  "(KHTML, like Gecko) Version/12.0 Safari/605.1.15",
                AutoresizingMask   = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable,
                NavigationDelegate = new NavigationDelegate()
            };

            webView.TranslatesAutoresizingMaskIntoConstraints = false;
            var req = new NSUrlRequest(new NSUrl(provider.Url));

            webView.LoadRequest(req);

            return(new WebViewWrapper(webView, provider));
        }
        public TrustlyWKWebView(string checkoutUrl, CGRect frame) : base(frame)
        {
            try
            {
                //Create a new content controller.
                var userContentController = new WKUserContentController();
                //Create configuration
                var configuration = new WKWebViewConfiguration();
                configuration.UserContentController = userContentController;
                configuration.Preferences.JavaScriptCanOpenWindowsAutomatically = true;

                //Crate a webview
                TrustlyView = new WKWebView(frame, configuration);
                TrustlyView.NavigationDelegate = this;
                TrustlyView.UIDelegate         = this;
                TrustlyView.NavigationDelegate = this;
                TrustlyView.UIDelegate         = this;

                //Add the trustly ScriptOpenURLScheme as a handler for this contentcontroller
                userContentController.AddScriptMessageHandler(new TrustlyWKScriptOpenURLScheme(TrustlyView), TrustlyWKScriptOpenURLScheme.NAME);

                var url = new NSUrl(checkoutUrl);

                TrustlyView.LoadRequest(new NSUrlRequest(url));
                TrustlyView.AllowsBackForwardNavigationGestures = true;

                AddSubview(TrustlyView);
                TrustlyView.TranslatesAutoresizingMaskIntoConstraints = false;
                TrustlyView.BottomAnchor.ConstraintEqualTo(TrustlyView.Superview.BottomAnchor, 0).Active     = true;
                TrustlyView.TopAnchor.ConstraintEqualTo(TrustlyView.Superview.TopAnchor, 0).Active           = true;
                TrustlyView.LeadingAnchor.ConstraintEqualTo(TrustlyView.Superview.LeadingAnchor, 0).Active   = true;
                TrustlyView.TrailingAnchor.ConstraintEqualTo(TrustlyView.Superview.TrailingAnchor, 0).Active = true;
            }
            catch { }
        }
示例#4
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var config = new WKWebViewConfiguration();

            //config.UserContentController.AddScriptMessageHandler(this, "interOp");

            _webView = new WKWebView(View.Frame, config);
            _webView.NavigationDelegate = this;
            _webView.TranslatesAutoresizingMaskIntoConstraints = false;
            View.AddSubview(_webView);

            var keys    = new object[] { "webview" };
            var objects = new object[] { _webView };
            var myViews = NSDictionary.FromObjectsAndKeys(objects, keys);

            //horizontal layout
            View.AddConstraints(NSLayoutConstraint.FromVisualFormat(@"|[webview]|", 0, null, myViews));
            //vertical layout
            View.AddConstraints(NSLayoutConstraint.FromVisualFormat(@"V:|-44-[webview]|", 0, null, myViews));

            var url     = new NSUrl("http://pelican-chart-demo.azurewebsites.net/Chart/Ciq?x=1s");
            var request = new NSUrlRequest(url);

            _webView.LoadRequest(request);
        }
示例#5
0
        void LoadInitialUrl(Uri url)
        {
            if (!webViewVisible)
            {
                progress.StopAnimating();
                webViewVisible = true;

                UIView.Transition
                (
                    fromView: authenticatingView,
                    toView: web_view,
                    duration: TransitionTime,
                    options: UIViewAnimationOptions.TransitionCrossDissolve,
                    completion: null
                );
            }

            if (url != null)
            {
                var request = new NSUrlRequest(new NSUrl(url.AbsoluteUri));
                NSUrlCache.SharedCache.RemoveCachedResponse(request); // Always try
                if (WebViewConfiguration.IOS.IsUsingWKWebView == false)
                {
                    ui_web_view.LoadRequest(request);
                }
                else
                {
                    wk_web_view.LoadRequest(request);
                }
            }

            return;
        }
示例#6
0
 public override void ViewDidLoad()
 {
     _webView = new WKWebView(View.Frame, new WKWebViewConfiguration());
     View.AddSubview(_webView);
     _webView.LoadRequest(new NSUrlRequest(new NSUrl("https://emarketua.azurewebsites.net/")));
     base.ViewDidLoad();
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = "Connect Account";
            View.BackgroundColor = ColorHelper.Background0.ToPlatformColor();

            var config = new WKWebViewConfiguration();

            config.ApplicationNameForUserAgent = "Version/8.0.2 Safari/600.2.5";

            // Create the webview
            _webView = new WKWebView(View.Frame, config);

            _urlObs = _webView.AddObserver("URL", NSKeyValueObservingOptions.New, async(o) =>
            {
                var newUrl = _webView.Url.ToString();
                await ViewModel.HandleRequestCommand.ExecuteAsync(newUrl);
            });

            View.AddSubview(_webView);

            // Navigate to the request url
            var url     = new NSUrl(ViewModel.AuthenticationDetails.ConnectUrl);
            var request = new NSUrlRequest(url);

            _webView.LoadRequest(request);

            // Cancel button
            NavigationItem.LeftBarButtonItem = new UIBarButtonItem("Cancel", UIBarButtonItemStyle.Plain, delegate { ViewModel.CloseCommand.Execute(); });
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var userController = new WKUserContentController();

            var scriptImage    = new WKUserScript(new NSString(JavaScriptFunctionForImage), WKUserScriptInjectionTime.AtDocumentEnd, false);
            var scriptVideo    = new WKUserScript(new NSString(JavaScriptFunctionForVideo), WKUserScriptInjectionTime.AtDocumentEnd, false);
            var scriptPDF      = new WKUserScript(new NSString(JavaScriptFunctionForPDF), WKUserScriptInjectionTime.AtDocumentEnd, false);
            var scriptAllFiles = new WKUserScript(new NSString(JavaScriptFunctionForDownloadAll), WKUserScriptInjectionTime.AtDocumentEnd, false);
            var scriptGetURL   = new WKUserScript(new NSString(JavaScriptFunction), WKUserScriptInjectionTime.AtDocumentEnd, false);

            userController.AddUserScript(scriptGetURL);
            userController.AddScriptMessageHandler(this, "callBack");

            webView = new WKWebView(new CoreGraphics.CGRect(0, 0, 375, 667), new WKWebViewConfiguration()
            {
                UserContentController = userController
            });
            webView.UIDelegate         = this;
            webView.NavigationDelegate = this;
            View.AddSubview(webView);
            webView.LoadRequest(new NSUrlRequest(url));
            StartActivityIndicatorWithText("Loading...", new CoreGraphics.CGRect(0, 0, 375, 667));
        }
        public void DecidePolicy(WKWebView webView, WKNavigationAction navigationAction, Action <WKNavigationActionPolicy> decisionHandler)
        {
            if (_handler == null)
            {
                return;
            }

            var navEvent       = WebNavigationEvent.NewPage;
            var navigationType = navigationAction.NavigationType;

            switch (navigationType)
            {
            case WKNavigationType.LinkActivated:
                navEvent = WebNavigationEvent.NewPage;

                if (navigationAction.TargetFrame == null)
                {
                    webView?.LoadRequest(navigationAction.Request);
                }

                break;

            case WKNavigationType.FormSubmitted:
                navEvent = WebNavigationEvent.NewPage;
                break;

            case WKNavigationType.BackForward:
                navEvent = _handler.CurrentNavigationEvent;
                break;

            case WKNavigationType.Reload:
                navEvent = WebNavigationEvent.Refresh;
                break;

            case WKNavigationType.FormResubmitted:
                navEvent = WebNavigationEvent.NewPage;
                break;

            case WKNavigationType.Other:
                navEvent = WebNavigationEvent.NewPage;
                break;
            }

            _lastEvent = navEvent;

            var virtualView = _handler.VirtualView;

            if (virtualView == null)
            {
                return;
            }

            var request = navigationAction.Request;
            var lastUrl = request.Url.ToString();

            bool cancel = virtualView.Navigating(navEvent, lastUrl);

            _handler.PlatformView?.UpdateCanGoBackForward(virtualView);
            decisionHandler(cancel ? WKNavigationActionPolicy.Cancel : WKNavigationActionPolicy.Allow);
        }
        protected override void CreateView()
        {
            Title = "Web View";

            WKWebView webView = new WKWebView(View.Frame, new WKWebViewConfiguration());

            View.AddSubview(webView);

            var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var filename2 = Path.Combine(documents, "xxx.pdf");


            var pdfUrl = NSBundle.MainBundle.GetUrlForResource("Tamarin", "pdf");

            //var request = new NSUrlRequest(new NSUrl(filename2, false));
            //var request = new NSUrlRequest(url);
            var request = new NSUrlRequest(pdfUrl);

            webView.LoadRequest(request);

            //_table = new UITableView();
            //_table.BackgroundColor = UIColor.Clear;
            //_table.RowHeight = UITableView.AutomaticDimension;
            //_table.EstimatedRowHeight = 44f;
            //Add(_table);

            //_webView = new UIWebView();
            //_webView.LoadRequest(new NSUrlRequest(url));
            //_webView.LoadData
        }
示例#11
0
 public override void ViewDidLoad()
 {
     base.ViewDidLoad();
     webView = new WKWebView(View.Frame, new WKWebViewConfiguration());
     View.AddSubview(webView);
     webView.LoadRequest(new NSUrlRequest(url));
 }
        private void PhoneNumberLogin()
        {
            string javaScript = @"var meta = document.createElement('meta');
                                   meta.setAttribute('name', 'viewport');
                                   meta.setAttribute('content', 'width=device-width');
                                   document.getElementsByTagName('head')[0].appendChild(meta);";

            WKUserScript            wkUScript     = new WKUserScript((NSString)javaScript, WKUserScriptInjectionTime.AtDocumentEnd, true);
            WKUserContentController wkUController = new WKUserContentController();

            wkUController.AddUserScript(wkUScript);

            WKWebViewConfiguration wkWebConfig = new WKWebViewConfiguration();

            wkWebConfig.UserContentController = wkUController;
            WKWebView webView = new WKWebView(View.Frame, wkWebConfig);

            View.AddSubview(webView);
            webView.AllowsBackForwardNavigationGestures = true;

            var url     = new NSUrl("http://34.216.71.66/Plaid/Plaid");
            var request = new NSUrlRequest(url);

            webView.LoadRequest(request);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            InitElements();
            UDID = UIDevice.CurrentDevice.IdentifierForVendor.ToString();
            backBn.TouchUpInside += (s, e) =>
            {
                this.NavigationController.PopViewController(true);
            };
            if (!methods.IsConnected())
            {
                NoConnectionViewController.view_controller_name = GetType().Name;
                this.NavigationController.PushViewController(sb.InstantiateViewController(nameof(NoConnectionViewController)), false);
                return;
            }
            InvokeInBackground(async() =>
            {
                string res_card_data = null;
                try
                {
                    res_card_data = await cards.CardDataGet(databaseMethods.GetAccessJwt(), card_id, UDID);
                }
                catch
                {
                    if (!methods.IsConnected())
                    {
                        InvokeOnMainThread(() =>
                        {
                            NoConnectionViewController.view_controller_name = GetType().Name;
                            this.NavigationController.PushViewController(sb.InstantiateViewController(nameof(NoConnectionViewController)), false);
                            return;
                        });
                    }
                    return;
                }
                if (/*res_card_data == Constants.status_code409 ||*/ res_card_data == Constants.status_code401)
                {
                    InvokeOnMainThread(() =>
                    {
                        ShowSeveralDevicesRestriction();
                        return;
                    });
                    return;
                }
                var des_card_data = JsonConvert.DeserializeObject <CardsDataModel>(res_card_data);
                InvokeOnMainThread(() =>
                {
                    urlString = new NSString(des_card_data.url);
                    NSUrl url = new NSUrl(urlString);
                    webView   = new WKWebView(View.Frame, new WKWebViewConfiguration());
                    View.AddSubview(webView);
                    var request = new NSMutableUrlRequest(url);
                    //request.HttpMethod = "Post";
                    webView.LoadRequest(request);
                    webView.Frame = new Rectangle(0, Convert.ToInt32(headerView.Frame.X + headerView.Frame.Height), Convert.ToInt32(View.Frame.Width), Convert.ToInt32(View.Frame.Height - headerView.Frame.Height));
                });
            });
        }
示例#14
0
        partial void OpenWebView(UIButton sender)
        {
            var webView = new WKWebView(View.Frame, new WKWebViewConfiguration());

            View.AddSubview(webView);

            webView.LoadRequest(new NSUrlRequest(url));
        }
示例#15
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);
            var url = new NSUrl("https://www.instagram.com/oauth/authorize/?client_id=a418ad2a645c485cb534972d5b3d8715&redirect_uri=https://www.google.com.ua/&response_type=token&scope=basic");

            _request = new NSUrlRequest(url);
            _webView.LoadRequest(_request);
        }
示例#16
0
        void HandleWKWebViewButtonTouchUpInside(object sender, EventArgs e)
        {
            var webView = new WKWebView(new CGRect(0, 20, View.Frame.Width, View.Frame.Height - 20), new WKWebViewConfiguration());

            View.AddSubview(webView);

            webView.LoadRequest(new NSUrlRequest(_googleNSUrl));
        }
 private void UpdateVideoPath()
 {
     if (_wkWebView != null && Element != null)
     {
         var url     = new NSUrl(Element.Source);
         var request = new NSUrlRequest(url);
         _wkWebView.LoadRequest(request);
     }
 }
示例#18
0
        public override void ViewDidDisappear(bool animated)
        {
            base.ViewDidDisappear(animated);

            ShouldClose = null;
            webView.LoadRequest(NSUrlRequest.FromUrl(new NSUrl("about:blank")));
            webView.NavigationDelegate = null;
            webView = null;
            AppDelegate.SetUsingViewController(false);
        }
示例#19
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = Resources.Loading;

            setNavBar();
            buildUI();

            webView.LoadRequest(new NSUrlRequest(new NSUrl(ViewModel.Url)));
        }
        public override void ViewDidLoad ()
        {
            base.ViewDidLoad ();

            webView = new WKWebView (View.Frame, new WKWebViewConfiguration ());
            View.AddSubview (webView);

            var url = new NSUrl ("https://evolve.xamarin.com");
            var request = new NSUrlRequest (url);
            webView.LoadRequest (request);
        }
示例#21
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            webView = new WKWebView(View.Frame, new WKWebViewConfiguration());
            View.AddSubview(webView);

            var url     = new NSUrl("https://evolve.xamarin.com");
            var request = new NSUrlRequest(url);

            webView.LoadRequest(request);
        }
示例#22
0
 public override void DidReceiveServerRedirectForProvisionalNavigation(WKWebView webView, WKNavigation navigation)
 {
     // We need to intercept the redirects to the app scheme because Safari will block them.
     // We will handle these redirects through the Navigation Manager.
     if (_currentUri?.Host == "0.0.0.0")
     {
         var uri = _currentUri;
         _currentUri        = null;
         _currentNavigation = null;
         var request = new NSUrlRequest(uri);
         webView.LoadRequest(request);
     }
 }
示例#23
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.White;

            Title = ViewModel.Title;

#pragma warning disable XI0002 // Notifies you from using newer Apple APIs when targeting an older OS version
            if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
            {
                NavigationItem.LargeTitleDisplayMode = UINavigationItemLargeTitleDisplayMode.Never;
            }
#pragma warning restore XI0002 // Notifies you from using newer Apple APIs when targeting an older OS version

            var shareButton = new UIBarButtonItem(UIBarButtonSystemItem.Action, OnShareButtonClick);
            NavigationItem.RightBarButtonItem = shareButton;

            var webConfig = new WKWebViewConfiguration();
            _webView = new WKWebView(CGRect.Empty, webConfig)
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                NavigationDelegate = this,
                UIDelegate         = this
            };
            View.AddSubview(_webView);

            var constraints = new[]
            {
                _webView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _webView.TopAnchor.ConstraintEqualTo(View.TopAnchor),
                _webView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                _webView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor)
            };

            View.AddConstraints(constraints);

            _loadBar = new UIProgressView(UIProgressViewStyle.Bar)
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            _loadBar.SizeToFit();

            View.AddSubview(_loadBar);

            var guide = this.GetCompatibleLayoutGuide();
            _loadBar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor).Active   = true;
            _loadBar.TopAnchor.ConstraintEqualTo(guide.TopAnchor).Active          = true;
            _loadBar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor).Active = true;

            _webView.LoadRequest(new NSUrlRequest(NSUrl.FromString(ViewModel.StoryUrl)));
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = ViewModel.Title;
            ItemDescriptionLabel.Text = ViewModel.Item.Description;
            web = new WKWebView(View.Frame, new WKWebViewConfiguration());
            View.AddSubview(web);

            var url     = new NSUrl(ViewModel.Item.Wiki);
            var request = new NSUrlRequest(url);

            web.LoadRequest(request);
        }
 private void UpdateWebView()
 {
     try
     {
         using (NSUrl url = new NSUrl(urlString))
         {
             var request = new NSMutableUrlRequest(url);
             webView.LoadRequest(request);
         }
     }
     catch
     {
     }
 }
示例#26
0
            // https://stackoverflow.com/questions/37509990/migrating-from-uiwebview-to-wkwebview
            public override void DecidePolicy(WKWebView webView, WKNavigationAction navigationAction, Action <WKNavigationActionPolicy> decisionHandler)
            {
                var navEvent       = WebNavigationEvent.NewPage;
                var navigationType = navigationAction.NavigationType;

                switch (navigationType)
                {
                case WKNavigationType.LinkActivated:
                    navEvent = WebNavigationEvent.NewPage;

                    if (navigationAction.TargetFrame == null)
                    {
                        webView?.LoadRequest(navigationAction.Request);
                    }

                    break;

                case WKNavigationType.FormSubmitted:
                    navEvent = WebNavigationEvent.NewPage;
                    break;

                case WKNavigationType.BackForward:
                    navEvent = _renderer._lastBackForwardEvent;
                    break;

                case WKNavigationType.Reload:
                    navEvent = WebNavigationEvent.Refresh;
                    break;

                case WKNavigationType.FormResubmitted:
                    navEvent = WebNavigationEvent.NewPage;
                    break;

                case WKNavigationType.Other:
                    navEvent = WebNavigationEvent.NewPage;
                    break;
                }

                _lastEvent = navEvent;
                var request = navigationAction.Request;
                var lastUrl = request.Url.ToString();
                var args    = new WebNavigatingEventArgs(navEvent, new UrlWebViewSource {
                    Url = lastUrl
                }, lastUrl);

                WebView.SendNavigating(args);
                _renderer.UpdateCanGoBackForward();
                decisionHandler(args.Cancel ? WKNavigationActionPolicy.Cancel : WKNavigationActionPolicy.Allow);
            }
        public override void DidReceiveServerRedirectForProvisionalNavigation(WKWebView webView, WKNavigation navigation)
        {
            // We need to intercept the redirects to the app scheme because Safari will block them.
            // We will handle these redirects through the Navigation Manager.
            if (_currentUri.Host == "0.0.0.0")
            {
                var uri = _currentUri;
                _currentUri        = null;
                _currentNavigation = null;
#pragma warning disable CA2000 // Dispose objects before losing scope
                var request = new NSUrlRequest(uri);
#pragma warning restore CA2000 // Dispose objects before losing scope
                webView.LoadRequest(request);
            }
        }
示例#28
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var configuration = new WKWebViewConfiguration();
            var cgRect        = new CoreGraphics.CGRect(0, 0, 400, 700);
            var webView       = new WKWebView(cgRect, configuration);

            webView.TranslatesAutoresizingMaskIntoConstraints = false;
            //WKNavigation  navigation  = new WKNavigation();
            webView.NavigationDelegate = (IWKNavigationDelegate)this;
            View.AddSubview(webView);
            var url     = new NSUrl("https://www.instagram.com/oauth/authorize/?client_id=f0c8c1093c06475dbeadba39c6b3ac80&redirect_uri=https://www.google.com.ua/&response_type=token&scope=basic");
            var reqvest = new NSUrlRequest(url);

            webView.LoadRequest(reqvest);
        }
示例#29
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View.BackgroundColor = UIColor.White;

            _wkWebView = PrepareWKWebView();

            EvaluateJava();

            View.AddSubview(_wkWebView);

            NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Cancel, CancelAuthentication);

            _wkWebView.LoadRequest(new NSUrlRequest(new NSUrl(_url)));
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var webView = new WKWebView(View.Frame, new WKWebViewConfiguration())
            {
                WeakNavigationDelegate = this
            };

            View.AddSubview(webView);

            var url     = new NSUrl("http://creditcardgatewayservice20170905011007.azurewebsites.net/");
            var request = new NSUrlRequest(url);

            webView.LoadRequest(request);
        }
示例#31
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.


            //Botón Web View
            btnVisorWeb1.TouchUpInside += delegate {
                WKWebView Webview = new WKWebView(View.Frame, new WKWebViewConfiguration()); //una nueva instancia que ocupa toda la pantalla y se le asigna configuración.
                View.AddSubview(Webview);                                                    //Se agrega directamente a la vista.
                var url     = new NSUrl("https://www.raywenderlich.com/ios/");
                var request = new NSUrlRequest(url);
                Webview.LoadRequest(request);
            };

            //Botón Web en Safari Services
            btnVisorWeb2.TouchUpInside += delegate {
                //Invocar a safiri services o invocar al navegador safari
                var url    = new NSUrl("https://www.raywenderlich.com/4919757-your-first-ios-and-swiftui-app");
                var safari = new SFSafariViewController(url); //invoca el services de safari.
                PresentViewController(safari, true, null);    //Aqui se invoca al navegador del dispositivo safari services.
            };

            //Botón Web Safari IOS
            btnVisorWeb3.TouchUpInside += delegate {
                //Aqui la aplicación queda en segundo plano

                var Url    = new NSUrl("https://www.raywenderlich.com/1320561-machine-learning-in-ios");
                var Opcion = new UIApplicationOpenUrlOptions();
                Opcion.OpenInPlace = true;
                UIApplication.SharedApplication.OpenUrl(Url, Opcion, null);
            };

            btnDocumentos.TouchUpInside += delegate {
                Elementos = new List <Elemento>()
                {
                    //Instancia a la clase Elemento
                    new Elemento("Power Point", NSUrl.FromFilename("Docs/uno.ppt")),
                    new Elemento("Word", NSUrl.FromFilename("Docs/dos.docx")),
                    new Elemento("Excel", NSUrl.FromFilename("Docs/tres.xlsx"))
                };

                Controlador            = new QLPreviewController(); //Se crea una nueva instancia.
                Controlador.DataSource = new OrigenDatos(Elementos);
                PresentViewController(Controlador, true, null);     //SEle arga el controlador.
            };
        }
示例#32
0
        //
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
              Title = "Test";

              View.Add(_scrollView);
              _scrollView.BackgroundColor = UIColor.FromRGB(235,235,235);
              _scrollView.FitToGuides(this, 0);

              for ( var idx = 0; idx < 10; idx++ )
              {
            var container = new Container();

            _scrollView.Add(container);

            if ( _scrollView.Subviews.Length == 1 )
            {
              container.Anchor(NSLayoutAttribute.Top, _scrollView, NSLayoutAttribute.Top, 10);
            }
            else
            {
              var prevView = _scrollView.Subviews[_scrollView.Subviews.Length - 2];
              container.Anchor(NSLayoutAttribute.Top, prevView, NSLayoutAttribute.Bottom, 10);
            }

            container
              .Anchor(NSLayoutAttribute.Left, _scrollView, NSLayoutAttribute.Left, 10)
              .Anchor(NSLayoutAttribute.Width, _scrollView, NSLayoutAttribute.Width, -20);

            container.ExpandedConstraint =
              NSLayoutConstraint.Create(
            container,
            NSLayoutAttribute.Height,
            NSLayoutRelation.Equal,
            _scrollView,
            NSLayoutAttribute.Height,
            1,
            -20);

            container.Header.Text = "hopla";

            //        var image = new UIImageView(UIImage.FromBundle("bloodborne.jpg"));
            //        container.Content.Add(image);
            //        image.FitToParent(0);

            var webView = new WKWebView(new CGRect(), new WKWebViewConfiguration());
            webView.ScrollView.ScrollEnabled = false;
            webView.Layer.BackgroundColor = UIColor.White.CGColor;

            container.Content = webView;

            webView.LoadRequest(new NSUrlRequest(new NSUrl("https://www.google.com")));
              }

              var finalView = _scrollView.Subviews[_scrollView.Subviews.Length - 1];
              finalView.Anchor(NSLayoutAttribute.Bottom, _scrollView, NSLayoutAttribute.Bottom, -10);
        }