Need to open a safari link from uiwebview?

I saved the entire html document with the escape sequence in a variable ... and it contains some anchor tag .. where, if it clicked, it should open in safari, and not in my webview application ....

+4
source share
2 answers

You can use the following code for this.

-(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType { if ( inType == UIWebViewNavigationTypeLinkClicked ) { [[UIApplication sharedApplication] openURL:[inRequest URL]]; return NO; } return YES; } 
+4
source

You can use the UIWebViewDelegate protocol for this:

 // assuming webView is a valid UIWebView webView.delegate = self; - (BOOL)webView:(UIWebView *)wv shouldStartLoadWithRequest:(NSURLRequest *)rq navigationType:(UIWebViewNavigationType)nt { if (nt == UIWebViewNavigationTypeLinkCkicked) { [[UIApplication sharedApplication] openURL:[rq URL]]; return NO; } return YES; } 
+3
source

All Articles