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 中打开链接?


基础教程推荐
- 在 iOS 上默认是 char 签名还是 unsigned? 2022-01-01
- Android文本颜色不会改变颜色 2022-01-01
- 如何使 UINavigationBar 背景透明? 2022-01-01
- 使用 Ryzen 处理器同时运行 WSL2 和 Android Studio 2022-01-01
- :hover 状态不会在 iOS 上结束 2022-01-01
- 固定小数的Android Money Input 2022-01-01
- 如何使用 YouTube API V3? 2022-01-01
- “让"到底是怎么回事?关键字在 Swift 中的作用? 2022-01-01
- Android ViewPager:在 ViewPager 中更新屏幕外但缓存的片段 2022-01-01
- LocationClient 与 LocationManager 2022-01-01