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];
}
}
本人菜鸟,以上都是自己的理解,有什么不对的地方,或者不合适的地方求大神指出来。谢谢大家了
首先创建第一个叫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];
}
}
本人菜鸟,以上都是自己的理解,有什么不对的地方,或者不合适的地方求大神指出来。谢谢大家了
相关文章推荐
- 详解移动端的Touch事件
- 详解移动端的Touch事件
- 实用的两个移动端demo
- 使用Android Studio开发J2SE项目方法
- MJPhotoBrowser一些bug的处理
- android_ant_library 多个library编译
- Android Studio 获取数字签名信息
- Android 内存溢出解决方案(OOM) 整理总结
- Android深入浅出之Binder机制
- Android开发手记(23) Notification
- Android LayoutInflater详解
- 【cocos2d-js系列问题】win7 Cocos2d-js 报Uncaught Error: child already added. It can't be added again 错误解决
- Unbalanced calls to begin/end appearance transitio
- Android——SharedPreferences
- 【cocos2d-js系列问题】win7 cocos2d-js 报ccs is not defined错误解决
- Android Tip 之倒计时功能
- android sdk
- Android插件-Android Holo Colors Generator
- Unity5.0中的新酷炫动画功能
- aapt.exe无法停止,android aapt 报错Type Error executing aapt: Return code -1073741819