博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iOS app之间的跳转以及传参数
阅读量:4066 次
发布时间:2019-05-25

本文共 1314 字,大约阅读时间需要 4 分钟。

//联系人:石虎  QQ: 1224614774昵称:嗡嘛呢叭咪哄

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

谢谢!!!

你可能感兴趣的文章
my ReadBook_zhulidianzishangwushi / dianzishangwushi
查看>>
script cmd / Execute a system command
查看>>
OS + Linux File nfs / ntfs / xfs / ext3 / ext4 / tmpfs / filemon recover lvm
查看>>
Linux + Video cache
查看>>
IBM Tivoli Omegamon
查看>>
my read_animal / chicken
查看>>
OS + Linux RedHat 5 Configuration / JDK / YUM
查看>>
webServer fscs 0.1.1
查看>>
IBM Technology Videos
查看>>
my read_bureaucracy
查看>>
Unix + OS IBM Aix Disk disk lvm / disk partition / disk mount / disk mon / File
查看>>
OS + Linux Disk disk lvm / disk partition / disk mount / disk io
查看>>
read_humor_international
查看>>
my read_Country
查看>>
OS + Linux File nfs / samba / rsync / inotify / smb / webdav
查看>>
RedHat + OS CPU、MEM、DISK
查看>>
project bbs_discuz
查看>>
net TCP/IP / TIME_WAIT / tcpip / iperf / cain
查看>>
Unix + OS books
查看>>
script webshell jspWebShell / pythonWebShell / phpWebShell
查看>>