iOS程序中调用系统自带应用(短信,邮件,浏览器,地图,appstore,拨打电话)
查看更多iPhone应用程序的调用和第三方应用程序的调用,可以在iPhone的URL方案查看。下面列举部分:
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];
It seems?that maps:// also opens up the Maps application.
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];
NSString *stringURL = @"http://www.youtube.com/watch?v=WZH30T99MaM";NSURL *url = [NSURL URLWithString:stringURL];[[UIApplication sharedApplication] openURL:url];
It also works with this URL (which normally brings the Flash video player used by YouTube):
NSString *stringURL = @"http://www.youtube.com/v/WZH30T99MaM";NSURL *url = [NSURL URLWithString:stringURL];[[UIApplication sharedApplication] openURL:url];
?
ChatCo
NSString *stringURL = @"irc://irc.example.domain/roomName";NSURL *url = [NSURL URLWithString:stringURL];[[UIApplication sharedApplication] openURL:url];
NSString *stringURL = @"irc://irc.example.domain/Nickname@roomName";NSURL *url = [NSURL URLWithString:stringURL];[[UIApplication sharedApplication] openURL:url];
NSString *stringURL = @"irc://irc.example.domain/Nickname!Realname@roomName";NSURL *url = [NSURL URLWithString:stringURL];[[UIApplication sharedApplication] openURL:url];