Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open links in Safari instead of UIWebVIew?

Tags:

ios

uiwebview

I have an app with a UIWebView inside a UIViewController. I load HTML from a web service as a string like this:

self.webView loadHTMLString:_string baseURL:nil 

Is it possible for the HTML links in this string to be opened in the browser and not in the UIWebView in my app? How can I do this?

I have tried this in the UIViewController that "hosts" the UIWebVIew:

-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {    if (navigationType == UIWebViewNavigationTypeLinkClicked) {      [[UIApplication sharedApplication] openURL:[request URL]];      return NO;    }    return YES; } 

It doesn't seem to be working....

Any ideas?

like image 733
treasure Avatar asked Dec 15 '10 17:12

treasure


People also ask

Does WKWebView use Safari?

Uses Nitro, a faster JavaScript engineWKWebView uses the Nitro JavaScript engine, also used by mobile Safari, which comes with significant performance improvements over UIWebView's older JavaScript engine.

What is Mobile Safari UIWebView?

It means that your web site was viewed using the UIWebView functionality on an iOS device (iPhone, iPad, iPod Touch). The UIWebView is different from the ordinary Safari browser, as it is not a stand-alone browser, but merely browser functionality that is embedded in a third party app.

Does WebView share cookies with Safari?

Cookies do appear to be shared between Safari and WebViews.


1 Answers

Have you set the delegate of the UIWebView to your UIViewController? There's nothing obviously wrong with your code as far as I can see, so it's likely to be something small like that.

like image 69
Stephen Darlington Avatar answered Sep 18 '22 00:09

Stephen Darlington