iPhone上URL Schemes的作用为应用程序提供了一个其他应用程序或者safari可以启动他的方法.
首先,看下如何在自己的应用程序中打开其它的应用程序:
1.打开Google Map
// Create your query ...
NSString* searchQuery = @"1 Infinite Loop, Cupertino, CA 95014";
// Be careful to always URL encode things like spaces and other symbols that aren't URL friendly
searchQuery = [addressText stringByAddingPercentEsc apesUsingEncoding: NSUTF8StringEncoding];
// Now create the URL string ...
NSString* urlString = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@", searchQuery];
// An the final magic ... openURL!
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlText]];
2.打开Mail
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://info@iphonedevelopertips.com"]]
3.打开电话
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8004664411"]];
4.打开SMS
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:55555"]];
5.打开AppStore
NSURL *appStoreUrl = [NSURL URLWithString:@"http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=291586600&mt=8"];
[[UIApplication sharedApplication] openURL:appStoreUrl];
利用OpenUrl打开指定应用
最新推荐文章于 2024-08-20 18:00:55 发布