如何在程序中启动其他程序(2)

接上篇:如何在程序中启动其他程序(1)

本篇讲解常见APP启动方法与参数传递

1、IOS系统自带的APPLE程序

  • Safari

NSString *stringURL = @"http://wiki.akosma.com/";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

另外类似feed://的也在Safari中打开

  • Maps

NSString *title = @"title";
float latitude = 35.4634;
float longitude = 9.43425;
int zoom = 13;
NSString *stringURL = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@@%1.6f,%1.6f&z=%d", title, latitude, longitude, zoom];
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

另外,maps://形式的也可以打开Maps

  • Phone

呼叫电话的链接以“tel://”开头,但是不能含有空格及括号(允许含有“-”和“+”号)

NSMutableString *phone = [[@"+ 12 34 567 89 01" mutableCopy] autorelease];
[phone replaceOccurrencesOfString:@" " 
                       withString:@"" 
                          options:NSLiteralSearch 
                            range:NSMakeRange(0, [phone length])];
[phone replaceOccurrencesOfString:@"(" 
                       withString:@"" 
                          options:NSLiteralSearch 
                            range:NSMakeRange(0, [phone length])];
[phone replaceOccurrencesOfString:@")" 
                       withString:@"" 
                          options:NSLiteralSearch 
                            range:NSMakeRange(0, [phone length])];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@", phone]];
[[UIApplication sharedApplication] openURL:url];


  • SMS

NSString *stringURL = @"sms:";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];
可以在后面跟一个电话号码,但是我们不能初始化短信的内容

  • Mail


  • Youtube


  • iTunes


  • App Store


  • iBooks


2、第三方软件:


参考:http://wiki.akosma.com/IPhone_URL_Schemes
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值