• app之间的跳转以及传参数


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

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

    bubuko.com,布布扣

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

    bubuko.com,布布扣

    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, strongRootViewController *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显示另一个页面传过来的数据。

  • 相关阅读:
    高二下期末考试
    LG月赛.7
    CF1187E
    P5440 【XR-2】奇迹
    P1084 疫情控制
    P1083 借教室
    P2680 运输计划
    P3128 [USACO15DEC]最大流Max Flow
    博弈入门
    HDU 1907
  • 原文地址:https://www.cnblogs.com/wyk19910103/p/5482287.html
Copyright © 2020-2023  润新知