• ios俩个APP之间跳转、传值,以及直接跳转到指定app页面 或者 app 评价页面 的方法


    两个APP之间的跳转是通过[[UIApplication sharedApplication] openURL:url]这种方式来实现的。

    1.首先设置第一个APP的url地址

    2.接着设置第二个APP的url地址

    3.需要跳转的时候

    NSString *urlString = [NSString stringWithFormat:@"AppJumpSecond://%@",textField.text];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];

    我这里将textField的文字也传过去

    同样的,在第二个页面也是如此

    NSString *urlString = [NSString stringWithFormat:@"AppJumpFirst://%@",textField.text];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];

    这样就能相互跳转了

    4.处理传过去的数据

    在上面传了textField的数据,接收时在AppDelegate的

    - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation方法里。

    在AppDelegate里设置属性

    @property (nonatomic, strong) RootViewController *rvc;

    didFinishLaunchingWithOptions方法里添加

    self.rvc = [[RootViewController alloc] init];
    UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:self.rvc];
    self.window.rootViewController = nc;

    添加代码块

    - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
    {
        self.rvc.textField.text = [[url host] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        return YES;
    }

    使得textField显示另一个页面传过来的数据。

    5.跳转到app页面 

    找到应用程序的描述链接,比如:http://itunes.apple.com/gb/app/yi-dong-cai-bian/id391945719?mt=8

    然后将 http:// 替换为 itms:// 或者 itms-apps://:

     itms://itunes.apple.com/gb/app/yi-dong-cai-bian/id391945719?mt=8
     itms-apps:// itunes.apple.com/gb/app/yi-dong-cai-bian/id391945719?mt=8  
    然后打开这个链接地址:
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms://itunes.apple.com/gb/app/yi-dong-cai-bian/id391945719?mt=8"]];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms-apps ://itunes.apple.com/gb/app/yi-dong-cai-bian/id391945719?mt=8"]];

    6.跳转到app的评价页面

    找到应用程序的ID  ,比如 131456789 

    //去app页面评价
    -(void)   gotoAppStorePageRaisal:(NSString *) nsAppId
    {
        NSString  * nsStringToOpen = [NSString  stringWithFormat: @"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%@",nsAppId  ];
        
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:nsStringToOpen]];
    }

    比如调用  [self  gotoAppStorePageRaisal:@"131456789"];

     

  • 相关阅读:
    🍖名称空间与作用域
    🍖文件打开模式 "t"
    🍖函数参数
    【转】LINQ中的Aggregate语法
    【转】c#中string.trimstart() 和string.trimend() 的用法
    1094 和为k的连续区间(暴力)
    1095 Anigram单词
    1031 骨牌覆盖 (斐波拉契数列)
    最长公共子序列(模板 LCSL)
    1092 回文字符串(LCSL_DP)
  • 原文地址:https://www.cnblogs.com/xiaochaozi/p/3850071.html
Copyright © 2020-2023  润新知