【发布时间】:2012-12-19 09:42:44
【问题描述】:
【问题讨论】:
【问题讨论】:
设置UIWebview的这个属性
yourWebView.dataDetectorTypes = UIDataDetectorTypeNone;
【讨论】:
当您想使用此方法时,首先将委托设置为UIWebView...
[self.webview setDelegate:sethere];
之后,您可以使用 UIWebView 的 shouldStartLoadWithRequest: 委托方法,在其中添加此类逻辑以禁用如下所示的超链接...
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType;
{
NSURL *loadURL = [[request URL]retain];
//change next line to whatever condition you need, e.g.
//[[loadURL relativeString] ....] contains a certain substring
//or starts with certain letter or ...
if([[loadURL scheme] isEqualToString: @"file"])
{
[loadURL release];
return TRUE;
}
[loadURL release];
return FALSE;
}
另请参阅此 webView:shouldStartLoadWithRequest:navigationType 链接中的参考
希望对你有帮助....
【讨论】:
您无法更改 UIWebView 中的内容,但您可以通过给 UIWebView 一个委托来禁用 UIWebView 响应其中的链接,并在您的代码中实现以下内容:
webView:shouldStartLoadWithRequest:navigationType: 将方法委托给return NO;
【讨论】: