- (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

最新文章

  1. 兼容IE8 input的placeholder的文字显示
  2. PB函数大全
  3. zhuang 自定义Xcode代码模板:Code Snippet
  4. 无线路由器WDS 桥接设置方法
  5. ASP.NET Web API身份验证和授权
  6. TreeView 读取 xml 显示节点
  7. Linux有问必答:如何在Linux中修改环境变量PATH
  8. PHP之set_error_handler()函数讲解
  9. Mac下开发常用目录
  10. poj2817WordStack(状压)
  11. 强大的数据库查询工具Database.NET 9.4.5018.42
  12. ubuntu 上配置python +selenium环境
  13. yii创建控制台命令
  14. codeforces369A
  15. zoj3195 联通树上三个点的路径长
  16. 解决提交按钮在IE浏览器正常在360浏览器不可用
  17. Jpa实体类生成图解
  18. 基于线程实现的生产者消费者模型(Object.wait(),Object.notify()方法)
  19. js 弹出新页面,避免被浏览器、ad拦截的一种办法
  20. 修改RocketMQ的NameServer端口

热门文章

  1. Flask——route
  2. angular 的ng-view,ngrouter
  3. tableview的顶部有一部分空白区域,并不是Cell的解决方法。
  4. Sql 数据引擎中删除用户名、密码信息
  5. linq 对Sum()函数的支持
  6. Eclipse is running in a JRE, but a JDK is required 解决方法(转)
  7. 浅谈Eclipse寻找JVM(JRE)的顺序机制(转)
  8. python模块使用案例
  9. Linux 夸平台 移植 Win32
  10. 什么是侧翼区(flanking region)和侧翼区单核苷酸多态性(Flanking SNPs)