iOS俩个APP之间跳转、传值

 

iOS俩个APP之间跳转、传值 

 

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

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

bubuko.com,布布扣

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

bubuko.com,布布扣

 

3.须要跳转的时候atom

?url

1spa

2.net

NSString *urlString = [NSString stringWithFormat:@"AppJumpSecond://%@",textField.text];code

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];orm

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

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

?

1

2

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方法里添加

?

1

2

3

self.rvc = [[RootViewController alloc] init];

UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:self.rvc];

self.window.rootViewController = nc;

添加代码块

?

1

2

3

4

5

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation

{

    self.rvc.textField.text = [[url host] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    return YES;

}

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

相关文章
相关标签/搜索