您的位置:首页 > 移动开发

iOS 两个app之间的跳转

2015-11-06 16:46 197 查看
朋友突然问到我这个问题,自己研究了会。简单的两个app之间的跳转。写了个demo给他了。下面是做的demo。

首先创建第一个叫jumpTest3的项目 在项目



添加完成之后。运行在模拟器上一下。
接着创建第二个叫jumpTest2的项目,在项目的Info.plist添加如下字段



添加上去。
然后再jumpTest2中实现

- (void)viewDidLoad {

[superviewDidLoad];

//添加红色的按钮

UIButton *button = [UIButtonbuttonWithType:UIButtonTypeCustom];

button.backgroundColor = [UIColorredColor];

button.frame=CGRectMake(100,100,100,
100);

[button addTarget:selfaction:@selector(clickJumeToAnotherApp)forControlEvents:UIControlEventTouchUpInside];

[self.viewaddSubview:button];

}

//点击红色按钮的时候去跳转

-(void)clickJumeToAnotherApp{

NSString *jumpString = [NSStringstringWithFormat:@"jumpTest3://hello"];

BOOL canOpen = [[UIApplicationsharedApplication]canOpenURL:[NSURLURLWithString:jumpString]];

NSLog(@"canOpen %d",canOpen);

if (canOpen) {

[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:jumpString]];

}else{

UIAlertView *alertView =[[UIAlertViewalloc]initWithTitle:@"未安装"message:@"友情提示"delegate:selfcancelButtonTitle:@"确定"otherButtonTitles:nil,nil];

[alertView show];

}

}

本人菜鸟,以上都是自己的理解,有什么不对的地方,或者不合适的地方求大神指出来。谢谢大家了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: