zoukankan      html  css  js  c++  java
  • 零碎知识整理-外链应用

    part1:URI方式跳转应用外地图类应用导航

    功能:首先获取该设备支持应用外地图类应用的列表->传入该应用的对应的接口参数,实现跳转->(若支持回跳转,在应用类传入相应的接口参数跳转回来)。

    实现:1.首先获取支持跳转的地图应用列表:

    if ( [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"http://maps.apple.com/"]]){
          //苹果地图...
        }
    if ( [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"baidumap://"]]){
            //百度地图...
        }
    if ( [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"iosamap://"]]){
            //高德地图...
        }

    2.查找各个跳转应用的api接口要求和协议格式,如高德:

    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"选择地图" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
    
    UIAlertAction *action = [UIAlertAction actionWithTitle:@"高德地图" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
                
                NSString *urlString = [[NSString stringWithFormat:@"iosamap://navi?sourceApplication=%@&backScheme=%@&lat=%f&lon=%f&dev=0&style=2",appName,urlScheme,coordinate.latitude, coordinate.longitude] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];   }];
            
            [alert addAction:action];}

    3.这个是跳转到地图类应用的导航类功能,因此部分应用如高德和google支持跳转后,回跳回原应用。一般都是通过一开始跳转的时候传入的接口来判断结束导航后跳转该原应用而实现跳转。

  • 相关阅读:
    在类中声明常量
    PHPStudy配置虚拟主机配置域名步骤
    PHPStudy配置虚拟主机步骤
    2019年7月22日星期一,简单的总结一下
    简单的面向对象
    session和cookie
    Jquery 事件绑定 bind 与on 的区别
    php try catch用法
    include,include_once,require,require_once的区别
    require与 include区别
  • 原文地址:https://www.cnblogs.com/ramboback/p/4735908.html
Copyright © 2011-2022 走看看