uiapplication参考文章地址: http://psvsps2.blogspot.com/2010/04/uiapplication-contents-application_20.html
在iOS开发中,经常需要调用其它App,如拨打电话、发送邮件等。UIApplication:openURL:方法是实现这一目的的最简单方法,该方法一般通过提供的url参数的模式来调用不同的App。
通过openURL方法可以调用如下应用:
调用浏览器(Safari Browser)模拟器测试可以
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http:google.com"]];
调用谷歌地图(Google Maps)模拟器测试可以。但是地址不知道如何取?
- NSString *addressText = @"7 Hanover Square, New York, NY 10004";
- addressText = [addressText stringByAddingPercentEscapesUsingEncoding: NSASCIIStringEncoding];
- NSString* urlText = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@", addressText];
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlText]];
调用邮件客户端(Apple Mail)模拟器调用效果
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://devprograms@apple.com"]];
拨号(Phone Number)模拟器调用效果
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://6463777303"]];
调用短信(SMS)模拟器调用效果
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://466453"]];
调用应用商店(AppStore)模拟器调用效果
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=291586600&mt=8"]];