【发布时间】:2012-07-09 08:21:19
【问题描述】:
在我的 WebView 中,当用户单击 WebView 中的链接时,该属性在哪里?我查看了文档并尝试了类似
[webView.request.URL description]
webView.request.URL.absoluteURL or absoluteString
,一切都是空白的。谢谢!
【问题讨论】:
标签: iphone
在我的 WebView 中,当用户单击 WebView 中的链接时,该属性在哪里?我查看了文档并尝试了类似
[webView.request.URL description]
webView.request.URL.absoluteURL or absoluteString
,一切都是空白的。谢谢!
【问题讨论】:
标签: iphone
像这样实现委托函数
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
if(navigationType == UIWebViewNavigationTypeLinkClicked)
{
// Its following the click on some link on the loaded webpage
NSString *strLink = [[request URL] absoluteString]; // Clicked Link URL
}
return YES; // return YES if you allow the page to load else return NO
}
希望对你有所帮助。
【讨论】:
当用户点击任何链接时,您需要捕获 webview 委托函数
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType { NSURL *url = [request URL]; NSString *link = [url absoluteString]; return YES; }
【讨论】:
不妨试试这个:
NSString *link = [webView.request.URL absoluteString];
希望这会有所帮助!
【讨论】: