Skip to content

Instantly share code, notes, and snippets.

@Mardaneus86
Last active August 12, 2017 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mardaneus86/90ead67ff6f3ab89194a5b09eabbb1f6 to your computer and use it in GitHub Desktop.
Save Mardaneus86/90ead67ff6f3ab89194a5b09eabbb1f6 to your computer and use it in GitHub Desktop.
public override async void ViewDidLoad ()
{
base.ViewDidLoad();
// Set to background color of website to load, so you don't get a white flash while loading the page
WebView.BackgroundColor = new UIColor(0, 0.635f, 0.925f, 1.0f); // equals #e3ebf3
// Prevent bounces so it feels more like an actual app
WebView.ScrollView.Bounces = false;
// Load the actual page
WebView.LoadRequest (new NSUrlRequest (new NSUrl ("https://example.com")));
}
public override void ViewDidLoad ()
{
WebView.ShouldStartLoad = (webView, request, navigationType) =>
{
// ...
return true; // Notify the WebView that it can handle the request
};
}
public override void ViewDidLoad ()
{
WebView.ShouldStartLoad = (webView, request, navigationType) =>
{
if (this.OpenInMDMBrowser(request))
{
// Naive implementation to change the URL scheme
UIApplication.SharedApplication.OpenUrl(
new NSUrl(
request.Url.AbsoluteString.Replace("http://", "mdmbrowser://").Replace("https://", "mdmbrowser://")
)
);
return false; // Notify the WebView that we handled the action ourselves
}
return true; // Notify the WebView that it can handle the request
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment