UIWebView phone links detection on iphone(iphone上的UIWebView电话链接检测)
问题描述
我的代码有些奇怪.我肯定会忘记一些东西,但我不知道是什么.我尝试在 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电话链接检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:iphone上的UIWebView电话链接检测


基础教程推荐
- “让"到底是怎么回事?关键字在 Swift 中的作用? 2022-01-01
- 固定小数的Android Money Input 2022-01-01
- 如何使 UINavigationBar 背景透明? 2022-01-01
- LocationClient 与 LocationManager 2022-01-01
- Android ViewPager:在 ViewPager 中更新屏幕外但缓存的片段 2022-01-01
- :hover 状态不会在 iOS 上结束 2022-01-01
- 如何使用 YouTube API V3? 2022-01-01
- 使用 Ryzen 处理器同时运行 WSL2 和 Android Studio 2022-01-01
- 在 iOS 上默认是 char 签名还是 unsigned? 2022-01-01
- Android文本颜色不会改变颜色 2022-01-01