Skip to content

Instantly share code, notes, and snippets.

@rolandkakonyi
Last active November 26, 2015 10:42
Show Gist options
  • Save rolandkakonyi/550bc48a8f821b2eb632 to your computer and use it in GitHub Desktop.
Save rolandkakonyi/550bc48a8f821b2eb632 to your computer and use it in GitHub Desktop.
Open URLs from UIWebView in Safari instead of replacing the current content
//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