Instantly share code, notes, and snippets.

Embed
What would you like to do?
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