Last active
November 26, 2015 10:42
-
-
Save rolandkakonyi/550bc48a8f821b2eb632 to your computer and use it in GitHub Desktop.
Open URLs from UIWebView in Safari instead of replacing the current content
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
//Add this to the UIWebView's delegate | |
- (BOOL)webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType { | |
//Check the navigation type to determine it is user click on a link | |
if (inType == UIWebViewNavigationTypeLinkClicked) { | |
//Open the URL with the system's browser (Safari) | |
[[UIApplication sharedApplication] openURL:[inRequest URL]]; | |
//Prevent webview to load the target of the link | |
return NO; | |
} | |
//In all the other cases load the resources | |
return YES; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment