跳转到指定app的实现
IOS中应用的跳转是通过URL实现的,因此在实现应用跳转之前我们要设置一下对应的URL。
图一(寻找配置软件的URL)

图二(具体配置选项)

注意:
如果IOS版本为IOS9 我们需要为app设置白名单。
实现跳转的前提是有这个app,因此我们需要把被跳转的app先运行,即安装到模拟器中。
如图三(在info中添加)

效果图四

代码:
//
//  ViewController.m
//  X
//
//  Created by ma c on 16/4/9.
//  Copyright ? 2016年 bjsxt. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIButton *button;
@end
@implementation ViewController
- (IBAction)GoU:(id)sender {
    
    //获取跳转app的URl
    NSURL * url = [NSURL URLWithString:@"U://"];
    //判断手机中是否安装了对应的app
    if ([[UIApplication sharedApplication] canOpenURL:url]) {
        //打开应用程序
        [[UIApplication sharedApplication]openURL:url];
    }
}
- (void)viewDidLoad {
    [super viewDidLoad];
}
@end
为了证明实现的是app之间的跳转:另附两张app的故事板截图
X:图五

U:图六

跳转到指定页面的实现
前提:我们想要从X跳转到U的朋友圈。
那么X的代码如下:
//
//  ViewController.m
//  X
//
//  Created by ma c on 16/4/9.
//  Copyright ? 2016年 bjsxt. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIButton *button;
@end
@implementation ViewController
- (IBAction)GoU:(id)sender {
    
    //获取跳转app的URl
    NSURL * url = [NSURL URLWithString:@"U://"];
    //判断手机中是否安装了对应的app
    if ([[UIApplication sharedApplication] canOpenURL:url]) {
        //打开应用程序
        [[UIApplication sharedApplication]openURL:url];
    }
}
- (IBAction)GoFriend:(id)sender {
    //获取跳转朋友圈的URl
    NSURL * url = [NSURL URLWithString:@"U://friend"];
    //判断手机中是否安装了对应的app
    if ([[UIApplication sharedApplication] canOpenURL:url]) {
        //打开朋友圈
        [[UIApplication sharedApplication]openURL:url];
    }
}
- (void)viewDidLoad {
    [super viewDidLoad];
}
@end
我们不能仅仅对X进行设置更要对U进行设置。
对U的代码操作在Appdeledate中。
代码如下:
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options{
    
    //将url转为字符串
    NSString * urlString = url.absoluteString;
    //判断是通过什么跳转过来的
    if ([urlString containsString:@"friend"]) {
        NSLog(@"在这里执行页面跳转即可。");
    }
    return YES;
}
效果图七如下
 
 
原文:http://www.cnblogs.com/wuyuxin/p/7045642.html