Pregunta

Tengo una aplicación de brecha telefónica que carga una aplicación HTML 5 en un navegador infantil. Los enlaces que están en las páginas cargados en el navegador infantil también se cargan en el navegador infantil. Me gustaría que estos enlaces se abran en Safari. ¿Cómo podría hacer eso?

Gracias

¿Fue útil?

Solución

Solo necesitas agregar esto en tu appdelegate.m

- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    NSURL *url = [request URL];

    // Intercept the external http requests and forward to Safari.app
    // Otherwise forward to the PhoneGap WebView
    if ([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"]) {
        [[UIApplication sharedApplication] openURL:url];
        return NO;
    }
    else {
        return [ super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType ];
    }
}

Espero que esto ayude

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top