1. Apply a jump
- (ibaction) openwangyi { // 1. Get Application Object UIApplication *app = [UIApplication sharedApplication]; // 2. Create an application that needs to be opened url // in the application jump, as long as there is a protocol header, Path optional #warning protocol header in Project settings-info-url types settings nsurl *url = [nsurl urlwithstring:@ "wangyi://"]; // 3. Open URL with Application if ([App canopenurl:url]) { // 3.1 determine if you can open [app openURL:url]; }else { // 3.2 Open App store Download nslog (@ "Open app store based on App id"); }}
2. Appdelegate Agent for application jump
/** * call * * @param application current application when opened by another application via URL * @param url Open url * * of the current program @return Successful processing */- (BOOL) Application: (uiapplication *) application Handleopenurl: (nsurl *) url{ // 1. Get Home Controller uinavigationcontroller *nav = (uinavigationcontroller *) Self.window.rootViewController; UIViewController *vc = nav.topViewController; nslog (@ "%@", url); // decide which URL to use to open the, to make the appropriate processing ( Jump to the appropriate controller) NSString *urlStr = url.absoluteString; if ([urlstr hasprefix:@ "Sina://login"]) { // intercept the application that opened our program scheme nsrange range = [ urlstr rangeofstring:@ "Sina://login?myscheme="]; nsstring *scheme = [urlStr substringFromIndex:range.length]; nslog (@ "Jump to Authorization Interface aaaaaaaaa %@", scheme);// if ([Vc iskindofclass:[viewcontroller class]) == yes) {#warning Performseguewithidentifier via sb show jump method, transfer scheme [vc performseguewithidentifier:@ "Home2accounts" sender:scheme];// } }else if ([urlstr hasprefix:@ "sina://view?id="]) { &nbSp; nslog (@ "Jump to Detail Interface bbbbbbbbbb"); [vc performseguewithidentifier:@ "Home2detail" sender:nil]; } return yes;} A new method after #warning ios7/** * called (new method) when it is opened by another application via a URL * * @param application Current Applications * @param url Open the url * @ of the current program param sourceapplication Open the current program's bundle identifier * @param annotation * * @return successfully processed */- (BOOL) Application: (uiapplication *) application openurl: (nsurl *) Url sourceapplication: (nsstring *) Sourceapplication annotation: (ID) annotation{#warning NOTE:   If a new method is implemented, old method old fails /* sourceapplication use: when we do some advertising, integration wall and other promotion when, can take advantage of this unique Table a record of which program the current program is being promoted open */ nslog (@ "%@ %@", url, sourceapplication); // 1. Get home controller UINavigationController *nav = (Uinavigationcontroller *) self.window.rootviewcontroller; uiviewcontroller *vc = Nav.topviewcontroller; nslog (@ "%@", url); // determine which URL opens the, to make the appropriate processing (jump to the appropriate controller) NSString *urlStr = url.absolutestring; if ([urlstr hasprefix:@ "Sina://login"]) { // Intercept the application that opened our program Scheme nsrange range = [urlstr rangeofstring:@ "Sina://login?myScheme="]; NSString *scheme = [urlStr substringfromindex:range.length]; nslog (@ "Jump to Authorization Interface %@", scheme); // if ([vc iskindofclass:[viewcontroller Class]] == yes) { [vc performseguewithidentifier:@ "Home2accounts" sender:scheme]; // } }else if ([urlstr hasprefix:@ "sina://view?id="]) { nslog (@ "Jump to Detail Interface"); &NBsp; [vc performseguewithidentifier:@ "Home2detail" sender: nil]; } return yes;}
3.prepareForSegue Controller Jump
Prepareforsegue Show connect jump. must be controller jump controller, cannot control jump controller
-(void) Prepareforsegue: (Uistoryboardsegue *) Segue Sender: (ID) sender{NSLog (@ "Home%@", sender); Uiviewcontroller *VC = Segue.destinationviewcontroller; if ([VC Iskindofclass:[tableviewcontroller Class]]) {//if the target controller of the jump is authorized, it is necessary to set scheme Tableviewcontroller *TBVC = VC; Tbvc.callscheme = sender; }}
Ios-Apply Jump