Created
November 8, 2012 19:25
-
-
Save heydona/4040955 to your computer and use it in GitHub Desktop.
Trapping non-standard URLs
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
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { | |
NSString *scheme = [[[request URL] scheme] lowercaseString]; | |
// Allow standard URLs through | |
NSSet *stdSchemes = [NSSet setWithObjects:@"http", @"file", nil]; | |
if ([stdSchemes containsObject:scheme]) { | |
return YES; | |
} | |
// We do something with the special RB scheme | |
if ([scheme isEqualToString:@"rb"]) { | |
if (!delegate) { | |
return NO; | |
} | |
NSString *event = [[[request URL] host] lowercaseString]; | |
if ([event isEqualToString:@"scrolled.bottom"]) { | |
if ([delegate respondsToSelector:@selector(webPageScrolledToBottom:)]) { | |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){ | |
[delegate webPageScrolledToBottom:_fileName]; | |
}); | |
} | |
} | |
} | |
return NO; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment