代碼段:[[UIApplication sharedApplication] openURL:url];瀏覽器
其中系統的url有:
1.Map http://maps.google.com/maps?q=Shanghai
2.Email mailto://myname@google.com
3.Tel tel://10086
4.Msg sms://10086app
- (IBAction)openMaps { oop
//打開地圖 google
NSString*addressText = @"beijing"; url
//@"1Infinite Loop, Cupertino, CA 95014"; spa
addressText =[addressText stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]; .net
NSString *urlText = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@",addressText]; orm
NSLog(@"urlText=============== %@", urlText); blog
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlText]]; get
}
- (IBAction)openEmail {
//打開mail // Fire off an email to apple support
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"mailto://devprograms@apple.com"]];
}
- (IBAction)openPhone {
//撥打電話
// Call Google 411
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://10086"]];
}
- (IBAction)openSms {
//打開短信
// Text toGoogle SMS
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://10086"]];
}
-(IBAction)openBrowser {
//打開瀏覽器
// Lanuch any iPhone developers fav site
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://my.oschina.net/u/2451177/blog/619114"]];
}