Jump between ios apps, pass values, and jump between ios apps

Source: Internet
Author: User

Jump between ios apps, pass values, and jump between ios apps
The jump between two apps is achieved through [[UIApplication sharedApplication] openURL: url.

1. First set the url of the first APP

2. Set the url of the second APP.

 

3. Jump

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

I will upload textField text here.

The same is true on the second page.

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

In this way, you can jump to each other.

4. Process uploaded data

After the textField data is uploaded

-(BOOL) application :( UIApplication *) application openURL :( NSURL *) url sourceApplication :( NSString *) sourceApplication annotation :( id) in the annotation method.

Set attributes in AppDelegate

@ Property (nonatomic, strong) RootViewController * rvc;

Add the didfinishlaunchingwitexceptions Method

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

Add code block

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

This allows textField to display data transmitted from another page.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.