作者:今天是星期天嘛_512 | 来源:互联网 | 2024-12-21 10:24
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.
我的代码中有一些奇怪的东西。我肯定会忘记一些事情,但我不知道是什么。我尝试在UIWebView中处理手机,短信mailto和http链接。
This is how i try :
这是我尝试的方式:
1/ instantiate the UIWebView :
1 /实例化UIWebView:
webview = [[UIWebView alloc] initWithFrame:CGRectMake(0,0,320,460)];
webview.opaque = NO;
webview.backgroundColor = [UIColor clearColor];
webview.userInteractiOnEnabled= YES;
webview.dataDetectorTypes = UIDataDetectorTypeAll;
2/ set the appropriate delegate :
2 /设置适当的代表:
[webview setDelegate: self];
3/ implement the delegate method (simplified version here) :
3 /实现委托方法(这里是简化版):
- (BOOL)webView:(UIWebView *)webView
shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType; {
NSURL *requestURL = [[ request URL] retain];
NSLog(@">>> %@", [requestURL scheme]);
[requestURL release];
return YES;
}
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 :
使用我的调试设备,当我触摸http链接时,将打印NSLog。当我触摸电话链接时,我有这样的确认消息:
alt text http://cahripub.com/images/bug.gif
alt text http://cahripub.com/images/bug.gif
With the iPhone Simulator, tel and http links are correctly printed by NSLog.
使用iPhone模拟器,NSLog可以正确打印tel和http链接。
Weird, no ?
很奇怪,不是吗?
1 个解决方案