Jump, pass value between iOS two apps

Source: Internet
Author: User

The jump between the two apps is achieved by [[uiapplication sharedapplication] Openurl:url] this way.

1. First set the URL address of the first app

2. Then set the URL address of the second app

3. When a jump is required

NSString *urlstring = [NSString stringWithFormat:@ "appjumpsecond://%@", Textfield.text]; [[UIApplication sharedapplication] Openurl:[nsurl urlwithstring:urlstring]];

I'm going to pass TextField's words over here.

Likewise, this is true on the second page.

NSString *urlstring = [NSString stringWithFormat:@ "appjumpfirst://%@", Textfield.text]; [[UIApplication sharedapplication] Openurl:[nsurl urlwithstring:urlstring]];

So we can jump to each other.

4. Handling data passed in the past

The TextField data is transmitted on it and received at the Appdelegate.

-(BOOL) application: (uiapplication *) application OpenURL: (nsurl *) URL sourceapplication: (NSString *) sourceapplication annotation: (id) annotation method.

Setting properties in Appdelegate

@property (nonatomic, strong) Rootviewcontroller *rvc;

Add in the didfinishlaunchingwithoptions method

SELF.RVC =*nc == NC;

Add code block

-(BOOL) Application: (UIApplication *) application OpenURL: (nsurl *) URL sourceapplication: (NSString *) sourceapplication annotation: (ID) annotation{    = [[url host] Stringbyreplacingpercentescapesusingencoding:nsutf8stringencoding];     return YES;}

Enables TextField to display data passed from another page.

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.