天天看點

App之間的跳轉

App之間的跳轉

1,添加URL Types項

a,打開項目中.xcodeproj下的info目錄,增加一項URL Typs

App之間的跳轉

2,配置URL Scheme

a,将URL identifie選項為com.KeYi.lsf

b,将URL Scheme選項的内容修改為lsf

 - (BOOL)application:(UIApplication *)application

            openURL:(NSURL *)url

  sourceApplication:(NSString *)sourceApplication

         annotation:(id)annotation

{

//抓取url

    if (!url) {

        return NO;

    }else {

        if ([[url host] isEqualToString:@"expert"]) {

            NSArray *codeArr = [[url query] componentsSeparatedByString:@"="];

            if (codeArr.count >0) {

                if (self.window.rootViewController) {

                    BaseTabBarController *tabBarController = (BaseTabBarController*)self.window.rootViewController;

                    BaseNavigationController * bnc = (BaseNavigationController*)tabBarController.selectedViewController;

                    HomeDetailController * hdc = [[HomeDetailController alloc]init];

                    hdc.expertInfoDic = @{@"expertUserId":codeArr[1]};

                    [bnc pushViewController:hdc animated:YES];

                }else {

                }

            }

            return YES;

        }else if ([[url host] isEqualToString:@"topic"]) {

            NSArray *codeArray = [[url query] componentsSeparatedByString:@"&"];

            NSArray *codeArr = [codeArray[0] componentsSeparatedByString:@"="];

            NSArray *otherArr  = [codeArray[1] componentsSeparatedByString:@"="];

            if (codeArr.count > 0) {

                    ExpertDetailController * edc = [[ExpertDetailController alloc]init];

                    edc.topicInfo = @{@"topicId":codeArr[1],@"expertUserId":otherArr[1]};

                    [bnc pushViewController:edc animated:YES];

        }

    }

...

}

本文轉自 卓行天下  51CTO部落格,原文連結:http://blog.51cto.com/9951038/1745924,如需轉載請自行聯系原作者

繼續閱讀