App应用之间跳转
来源:互联网 发布:房屋免费设计软件 编辑:程序博客网 时间:2024/05/16 08:53
一个程序如果需要跳转到另一个程序,则需要在info.plist文件中添加URL Types,展开之后修改信息,在URL Schemes中添加key值,相当于跳转的URL,如下:
在BuyApp中
- (IBAction)gotoPay:(UIButton *)sender{ //要跳转到某个APP,需要知道这个APP的URL,打开这个URL即可跳转(URL中不能有空格,而且空格用&) NSURL *url = [NSURL URLWithString:@"Pay://?name=iphone8&price=5000"]; [[UIApplication sharedApplication]openURL:url];}
则在接受的PayApp的Appdelete文件中
//当本应用APP被其他APP打开时调用- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{ UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:[NSString stringWithFormat:@"%@",url] delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil]; [alert show]; //把url转成string NSString *urlString = url.absoluteString; //先截取参数,获取?右边的参数 NSString *param = [[urlString componentsSeparatedByString:@"?"]lastObject]; //分割各个参数 NSArray *paramArray = [param componentsSeparatedByString:@"&"]; //获取=右边商品名字参数 NSString *name = [[[paramArray objectAtIndex:0]componentsSeparatedByString:@"="]lastObject]; //获取=右边价钱参数 NSString *price = [[[paramArray objectAtIndex:1]componentsSeparatedByString:@"="]lastObject]; //将商品名字、价格先存起来 [[NSUserDefaults standardUserDefaults]setObject:name forKey:@"name"]; [[NSUserDefaults standardUserDefaults]setObject:price forKey:@"price"]; [[NSUserDefaults standardUserDefaults]synchronize]; //或者发通知 [[NSNotificationCenter defaultCenter]postNotificationName:@"getName" object:self userInfo:@{@"name":name,@"price":price}]; return YES;}同理:返回也是一样的操作,效果如下:
7 0
- App应用之间跳转
- App之间跨应用跳转
- app应用之间的跳转代码
- IOS两个App应用之间的跳转
- IOS两个App应用之间的跳转
- iOS两个App应用之间的跳转
- iOS两个App应用之间的跳转
- iOS两个app应用之间的互相跳转
- App之间跳转
- app 之间跳转(iOS)
- 两个APP之间跳转
- iOS App之间跳转
- app之间跳转
- Android应用之间的跳转—从一个app跳转至另一个app
- IOS应用之间跳转
- IOS应用之间跳转
- 应用之间跳转
- ios应用之间跳转
- Java 集合系列17之 TreeSet详细介绍(源码解析)和使用示例
- VarPtr(a)
- 假期
- BTrace系列之四:破解案例
- androd 集成alipay
- App应用之间跳转
- 保留分页符 删除WORD空白页
- Java 集合系列18之 Iterator和Enumeration比较
- BTrace系列之五:实现原理
- 跟我一起学Multiple View Geometry多视图几何(4)
- HTML、CSS、JavaScript判断 IE
- django 多数据库
- java-接口回调
- js的原型模式