问题描述
我的代码有些奇怪.我肯定会忘记一些东西,但我不知道是什么.我尝试在 UIWebView 中处理电话、短信、mailto 和 http 链接.
there is something strange in my code. I'm sure to forget something but i don't know what. I try to handle phone, sms mailto and http links in an UIWebView.
这就是我尝试的方式:
1/实例化 UIWebView :
1/ instantiate the UIWebView :
webview = [[UIWebView alloc] initWithFrame:CGRectMake(0,0,320,460)];
webview.opaque = NO;
webview.backgroundColor = [UIColor clearColor];
webview.userInteractionEnabled = YES;
webview.dataDetectorTypes = UIDataDetectorTypeAll;
2/设置适当的委托:
[webview setDelegate: self];
3/实现委托方法(这里是简化版):
3/ implement the delegate method (simplified version here) :
- (BOOL)webView:(UIWebView *)webView
shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType; {
NSURL *requestURL = [[ request URL] retain];
NSLog(@">>> %@", [requestURL scheme]);
[requestURL release];
return YES;
}
当我触摸一个 http 链接时,我的调试设备会打印 NSLog.当我触摸电话链接时,我会收到这种确认消息:
With my debug device when i touch an http link, the NSLog is printed. When i touch a tel link i have this kind of confirmation message :
(来源:cahripub.com)
使用 iPhone 模拟器,NSLog 可以正确打印 tel 和 http 链接.
With the iPhone Simulator, tel and http links are correctly printed by NSLog.
很奇怪,不是吗?
推荐答案
对于现在正在看这个的任何人,都可以这样做:
For anyone looking at this now, this will do it:
self.webView.dataDetectorTypes = UIDataDetectorTypeNone;
这篇关于iphone上的UIWebView电话链接检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!