码迷,mamicode.com
首页 > Web开发 > 详细

wkwebview a target="_blank" 打不开链接的解决方案

时间:2016-09-08 18:12:03      阅读:775      评论:0      收藏:0      [点我收藏+]

标签:

- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
{
    //this is a ‘new window action‘ (aka target="_blank") > open this URL externally. If we´re doing nothing here, WKWebView will also just do nothing. Maybe this will change in a later stage of the iOS 8 Beta
    if (!navigationAction.targetFrame) { 
        NSURL *url = navigationAction.request.URL;
        UIApplication *app = [UIApplication sharedApplication];
        if ([app canOpenURL:url]) {
            [app openURL:url];
        }
    }
    decisionHandler(WKNavigationActionPolicyAllow);
}

wkwebview a target="_blank" 打不开链接的解决方案

标签:

原文地址:http://www.cnblogs.com/xiangjune/p/5853893.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!