iOS [UIApplication sharedApplication] openURL等常用的方法使用例如:打电话、定位等

1、打电话

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://电话号码"]];

2、发短信

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://电话号码"]];

3、去设置设置APP定位权限

NSURL *settingsURL = [NSURL URLWithString:UIApplicationOpenSettingsURLString];

[[UIApplicationsharedApplication] openURL:settingsURL];

4、调用Safari打开页面

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://eyecm.com"]];

5、调用APP商店

NSURL *url= [NSURL URLWithString:@"http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=291586600&mt=8"];

[[UIApplication sharedApplication] openURL:url];

6、调用appstore商店评论

NSInteger apple_id = 121212;

NSString *str = [NSString stringWithFormat:

                                 @"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%ld",

                                 (long)apple_id ];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];

7、调用邮件客户端(Apple Mail)

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://[email protected]"]];

8、调用谷歌地图(Google Maps)

NSString *searchQuery = @"1 Infinite Loop, Cupertino, CA 95014";

searchQuery = [addressText stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];

NSString *urlString=[NSString stringWithFormat:@"http://maps.google.com/maps?q=%@", searchQuery];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlText]];

 

你可能感兴趣的:(iOS,OC,苹果)