在Safari中打开链接而不是UIWebVIew? [英] Open links in Safari instead of UIWebVIew?

查看:91
本文介绍了在Safari中打开链接而不是UIWebVIew?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 UIViewController 中有一个带有 UIWebView 的应用程序。我将Web服务中的HTML加载为如下字符串:

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

此字符串中的HTML链接是否可以在浏览器中打开而不是在我的应用程序中的UIWebView中打开?我怎么能这样做?

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?

我在UIViewController中试过这个托管UIWebVIew:

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....

任何想法?

推荐答案

您是否设置了<$ c $的代表c> UIWebView 到您的 UIViewController ?就我所见,你的代码没有任何明显的错误,所以它很可能是那么小的。

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.

这篇关于在Safari中打开链接而不是UIWebVIew?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆