Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIWebView phone links detection on iphone

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.

This is how i try :

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/ set the appropriate delegate :

[webview setDelegate: self];

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;
}

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 :

alt text
(source: cahripub.com)

With the iPhone Simulator, tel and http links are correctly printed by NSLog.

Weird, no ?

like image 779
lefakir Avatar asked Dec 16 '09 10:12

lefakir


1 Answers

For anyone looking at this now, this will do it:

self.webView.dataDetectorTypes = UIDataDetectorTypeNone;
like image 79
Matjan Avatar answered Sep 19 '22 10:09

Matjan