Reputation: 975
I want to get the url of the link when it is clicked in UIWebView .
I am using this code
NSString *currentURL = [NSString stringWithFormat:@"%@", webview.request.URL.absoluteString];
NSLog(@"Current URL == %@",currentURL);
It gives me null
Current URL == (null)
Upvotes: 1
Views: 678
Reputation: 397
Try this In Webview Method :
- (BOOL) webView: (UIWebView *) webView shouldStartLoadWithRequest: (NSURLRequest *) request navigationType: (UIWebViewNavigationType) navigationType{
NSURL *url = request.URL;
NSLog(@"%@", url.absoluteString);
NSURL *url = request.URL;
NSLog(@"%@", url.absoluteString);
if ([url.host containsString:@"www.google.co.in"])
{
nslog(@"Google")
}else{
}
}
Upvotes: 1