我希望在UIWebView中单击链接时获取该链接的URL。
我正在使用此代码
NSString *currentURL = [NSString stringWithFormat:@"%@", webview.request.URL.absoluteString];
NSLog(@"Current URL == %@",currentURL);
它给我null
Current URL == (null)
答案 0 :(得分:1)
试试这个 在Webview方法中:
- (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{
}
}