你可以使用openUrl打开一些程序,不只是浏览器,我们将在下面的例子中演示这些这些应用:
打开浏览器打开google map打开email拨号程序发短信程序打开appstore
到googlemap的URL格式是:
http://maps.google.com/maps?q=${QUERY_STRING}
你可以更改QUERY_STRING改变位置信息:
NSString* searchQuery = @"the postion I want to know"; searchQuery = [searchQuery stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; NSString* urlString = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@", searchQuery]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString: urlString]];格式:
mailto://${EMAIL_ADDRESS}
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://info@iphonedevelopertips.com"]];
格式:
tel://${PHONE_NUMBER}
1 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8004664411"]];
发短信
格式
sms:${PHONENUMBER_OR_SHORTCODE}
1 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:55555"]];
打开app store
打开appstore的程序位置,右键点击程序图标获取url
格式如下:
http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=291586600&mt=8
1 2 NSURL *appStoreUrl = [NSURL URLWithString:@"http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=291586600&mt=8"]; [[UIApplication sharedApplication] openURL:appStoreUrl];
转载于:https://www.cnblogs.com/w-zhijun/archive/2012/04/27/2473987.html
相关资源:JAVA上百实例源码以及开源项目