Reputation: 3324
I am using the code below to detect a link tap on my uiwebview. Is there a way to get the text of the link that has been tapped by the user?
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
NSLog(@"link tapped");
if(navigationType == UIWebViewNavigationTypeLinkClicked) {
//if (overrideLinksSwitch.on == TRUE) {
NSLog(@"navigation link tapped");
// [self myMethodAction];
// [myWebView stopLoading];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:linktapped]];
return NO;
}
return YES;
}
Any help appreciated.
Upvotes: 0
Views: 869
Reputation: 4254
NSURLRequest
has a URL
property. NSURLRequest
Just get the URL from the request
object in your method.
Upvotes: 2