zoukankan      html  css  js  c++  java
  • 如何处理webView跳转

    - (void)webView:(UIWebView *)wv didFailLoadWithError:(NSError *)error {
        // Give iOS a chance to open it.
        NSURL *url = [NSURL URLWithString:[error.userInfo objectForKey:@"NSErrorFailingURLStringKey"]];
        if ([error.domain isEqual:@"WebKitErrorDomain"]
            && error.code == 101
            && [[UIApplication sharedApplication]canOpenURL:url])
        {
            [[UIApplication sharedApplication]openURL:url];
            return;
        }

        // Normal error handling…
    }
     
    - (BOOL)webView:(UIWebView *)wv shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {

        // Determine if we want the system to handle it.
        NSURL *url = request.URL;
        if (![url.scheme isEqual:@"http"] && ![url.scheme isEqual:@"https"]) {
            if ([[UIApplication sharedApplication]canOpenURL:url]) {
                [[UIApplication sharedApplication]openURL:url];
                return NO;
            }
        }
        return YES;
    }
     
    - (void)webView:(UIWebView *)wv didFailLoadWithError:(NSError *)error {
        // Ignore NSURLErrorDomain error -999.
        if (error.code == NSURLErrorCancelled) return;

        // Ignore "Fame Load Interrupted" errors. Seen after app store links.
        if (error.code == 102 && [error.domain isEqual:@"WebKitErrorDomain"]) return;

        // Normal error handling…
    }
     
    转自:http://stackoverflow.com/questions/4299403/how-to-handle-app-urls-in-a-uiwebview
  • 相关阅读:
    Redis代理与集群的总结报告
    redis代理对比,redis架构对比,redis predixy安装和功能测试
    kafka学习方向系列
    redis-cluster-proxy安装使用尝试
    redis6集群安装与运维管理
    kafka集群搭建(利用集成zk集群)
    vue-property-decorator用法介绍
    软件世界的基石:重要开源项目盘点
    ECMAScript 6 入门
    windows下快速删除node_modules
  • 原文地址:https://www.cnblogs.com/jyking/p/5253048.html
Copyright © 2011-2022 走看看