Detección de enlaces del teléfono UIWebView en iphone
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.
Así es como lo intento:
1 / instanciar el UIWebView:
webview = [[UIWebView alloc] initWithFrame:CGRectMake(0,0,320,460)];
webview.opaque = NO;
webview.backgroundColor = [UIColor clearColor];
webview.userInteractionEnabled = YES;
webview.dataDetectorTypes = UIDataDetectorTypeAll;
2 / establecer 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 de teléfono tengo este tipo de mensaje de confirmación:
texto alternativo http://cahripub.com/images/bug.gif
Con el simulador de iPhone, NSLog imprime correctamente los enlaces de teléfono y http.
Raro, no?