Created
July 1, 2009 23:31
-
-
Save jfricker/139149 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType; | |
| { | |
| NSURL *loadURL = [ [ request URL ] retain ]; // retain the loadURL for use | |
| if (([[loadURL scheme] isEqualToString: @"http"] || | |
| [[loadURL scheme] isEqualToString: @"https"] ) && | |
| (navigationType == UIWebViewNavigationTypeLinkClicked)) // Check if the scheme is http/https. You can also use these for custom links to open parts of your application. | |
| return ![[UIApplication sharedApplication] openURL:[loadURL autorelease]]; // Auto release the loadurl because we wont get to release later. then return the opposite of openURL, so if safari cant open the url, open it in the UIWebView. | |
| [loadURL release]; | |
| return YES; // URL is not http/https and should open in UIWebView | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment