Here’s a handy fix for circumstances where you have a PDF and want to jump to the #anchor tags all over the place.
– (BOOL)webView:(UIWebView *)webView
shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType {
NSLog(@”108 request.URL=%@”, request.URL);
if(navigationType == UIWebViewNavigationTypeLinkClicked) {
NSLog(@”Link Clicked request.URL=%@”, request.URL);
NSString *hashString = [request.URL.absoluteStringstringByReplacingOccurrencesOfString:@”about:///”withString:@””];
hashString = [NSString stringWithFormat:@”window.location.href = ‘%@’;”, hashString];
[webView stringByEvaluatingJavaScriptFromString:hashString];
returnYES; //prevent tapped URL from loading inside the UIWebView.
}
return YES;
}