Feature implementation: A jumps to B and opens the specified page in b
Steps:
1. First create two projects (Project A, Project B), add a URL Types to the Info.plist file in Project B, as shown in the following illustration: Where the URL idenifier is the bundle ID of Project B, and the URL schemes adds a command prefix that I use here. ProjectB ", the name can be taken by itself, run the project B.
2. Add jump code in Project a
[[UIApplication sharedapplication] openurl:[nsurl urlwithstring:@ "projectb://"];
The command prefix for the URL must be the same as it was previously defined, and I added this line of code to a button click Method, and now click the button to jump to item B.
3. Now next to the app jump communication, in fact, with the value of almost. The click Method for the second button in item a adds code
[[UIApplication sharedapplication] openurl:[nsurl urlwithstring:@ "Projectb://openbsecondpage"];
4. Add a Nsurl attribute to appdelegate in Project B to implement an agent method to receive URLs from project a
-(BOOL) Application: (UIApplication *) application Handleopenurl: (nsurl *) URL
{
self.url = URL;
Return YES
}
Then add code to the first interface in B
-(void) viewdidload {
[super viewdidload];
Nsurl * url = ((Appdelegate *) [uiapplication sharedapplication].delegate). url;
if (URL) {
//show Url,url = Projectb://openbsecondpage,host = openbsecondpage
self.label.text = [NSString stringwithformat:@ "url =%@,host =%@", [url Absolutestring],[url host]];
Perform some actions according to the host of the URL that is passed in
([[url host]isequaltostring:@ "Openbsecondpage"]) {
//jump to the second interface
[self performseguewithidentifier:@ "Second" Sender:nil];}}
In short, you do some custom actions based on the URL that comes from a that opens project B