2009-12-16 9 views
8

hay algo extraño en mi código. Estoy seguro de olvidar algo, pero no sé qué. Intento manejar los enlaces de teléfono, sms mailto y http en un UIWebView.UIWebView enlaces de teléfono detección en iphone

esto es cómo i trato:

1/instanciar los 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 el delegado apropiado:

[webview setDelegate: self]; 

3/implementar el método delegado (versión simplificada aquí):

- (BOOL)webView:(UIWebView *)webView 
shouldStartLoadWithRequest:(NSURLRequest *)request 
    navigationType:(UIWebViewNavigationType)navigationType; { 

    NSURL *requestURL = [[ request URL] retain]; 
    NSLog(@">>> %@", [requestURL scheme]); 
    [requestURL release]; 
    return YES; 
} 

Con mi dispositivo de depuración cuando toco un enlace http, se imprime el NSLog. Cuando toco un enlace tel tengo este tipo de mensaje de confirmación:

alt text http://cahripub.com/images/bug.gif

Con el simulador de iPhone, enlaces http tel y se imprimen correctamente por NSLog.

Weird, no?

+0

precisión, he intentado un poco con cada valores dataDetectorTypes! – lefakir

+0

He intentado con sms y enlaces de mailto. También están correctamente impresos por NSLog. – lefakir

Respuesta

5

Para todos aquellos que buscan en este momento, esto hará que:

self.webView.dataDetectorTypes = UIDataDetectorTypeNone; 
Cuestiones relacionadas