![](/img/trans.png)
[英]IOS - UIWebview - Get the URL of the link clicked and edit the url
[英]Get url when a link is clicked in UIWebView
我想在UIWebView中单击链接时获得链接的URL。
我正在使用此代码
NSString *currentURL = [NSString stringWithFormat:@"%@", webview.request.URL.absoluteString];
NSLog(@"Current URL == %@",currentURL);
它给了我空
Current URL == (null)
在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{
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.