Last active
August 12, 2017 14:33
-
-
Save Mardaneus86/90ead67ff6f3ab89194a5b09eabbb1f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"))); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public override void ViewDidLoad () | |
{ | |
WebView.ShouldStartLoad = (webView, request, navigationType) => | |
{ | |
// ... | |
return true; // Notify the WebView that it can handle the request | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WebView.ShouldStartLoad = (webView, request, navigationType) => | |
{ | |
if (this.IsPasswordChange(request)) | |
{ | |
var alertController = UIAlertController.Create("Change password", | |
"You can't change your password through this app.", UIAlertControllerStyle.Alert); | |
// Add action | |
alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); | |
// Present alert | |
PresentViewController(alertController, true, null); | |
return false; // Notify the WebView that we handled the action ourselves | |
} | |
return true; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment