zoukankan      html  css  js  c++  java
  • iOS 程序间跳转传参(支付和地图)

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

  • 相关阅读:
    Linux的基础优化
    Linux日志文件/var/log详解
    Linux下inittab文件详解
    Linux内核优化
    Linux虚拟机网络连接的三种方式
    Linux下ssh的使用
    nginx安装Lets Encrypt SSL免费HTTPS加密证书
    centos7.2 安装 nginx
    CentOS 7 安装php7
    linux tar 解压出错
  • 原文地址:https://www.cnblogs.com/pruple/p/5609768.html
Copyright © 2011-2022 走看看