Open links in Safari instead of UIWebVIew?(在 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?
我已经在托管"UIWebVIew 的 UIViewController 中尝试过这个:
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;
}
好像没用……
有什么想法吗?
推荐答案
你设置了 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 中打开链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Safari 而不是 UIWebVIew 中打开链接?
基础教程推荐
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- iOS4 创建后台定时器 2022-01-01
