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 中打开链接?
				
        
 
            
        基础教程推荐
- Xcode UIView.init(frame:) 只能在主线程中使用 2022-01-01
 - 为什么姜饼模拟器方向卡在应用程序中? 2022-01-01
 - Play 商店的设备兼容性问题 2022-01-01
 - SwiftUI-ScrollViewReader的ScrollTo不滚动 2022-01-01
 - 如何比较两个 NSDate:哪个是最近的? 2022-01-01
 - UIImage 在开始时不适合 UIScrollView 2022-01-01
 - Android Volley - 如何动画图像加载? 2022-01-01
 - iOS - UINavigationController 添加多个正确的项目? 2022-01-01
 - 如何将图像从一项活动发送到另一项活动? 2022-01-01
 - navigationItem.backBarButtonItem 不工作?为什么上一个菜单仍然显示为按钮? 2022-01-01
 
    	
    	
    	
    	
    	
    	
    	
    	
				
				
				
				