[转] ios学习--openURL的使用方法
openURL的使用方法:
view plaincopy toclipboardprint?
???????[[UIApplication?sharedApplication]?openURL:[NSURL?URLWithString:appString]];??
其中系統的appString有:
1.Map????http://maps.google.com/maps?q=Shanghai??
2.Email??mailto://myname@google.com??
3.Tel????tel://10086??
4.Msg????sms://10086??
openURL能幫助你運行Maps,SMS,Browser,Phone甚至其他的應用程序。這是Iphone開發中我經常需要用到的一段代碼,它僅僅只有一行而已。
- (IBAction)openMaps {
????//打開地圖?
???NSString*addressText = @"beijing";
????//@"1Infinite Loop, Cupertino, CA 95014";?
???addressText =[addressTextstringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];?
???NSString*urlText = [NSStringstringWithFormat:@"http://maps.google.com/maps?q=%@",addressText];?
???NSLog(@"urlText=============== %@", urlText);
???[[UIApplicationsharedApplication] openURL:[NSURL URLWithString:urlText]];
}
- (IBAction)openEmail {
?????//打開mail // Fire off an email to apple support
??????[[UIApplication sharedApplication]openURL:[NSURL???URLWithString:@"mailto://devprograms@apple.com"]];
?}?
?
- (IBAction)openPhone {
??
??? //撥打電話
??? // CallGoogle 411
? ??[[UIApplication sharedApplication] openURL:[NSURLURLWithString:@"tel://8004664411"]];
?}?
?
- (IBAction)openSms {
????//打開短信
? ?? // Text toGoogle SMS
????[[UIApplication sharedApplication] openURL:[NSURLURLWithString:@"sms://466453"]];
}
-(IBAction)openBrowser {
????//打開瀏覽器
????// Lanuch any iPhone developers fav site
? ? ?[[UIApplication sharedApplication] openURL:[NSURLURLWithString:@"http://itunesconnect.apple.com"]];
?}
iphone程序內調用谷歌地圖
使用CLLocationManager類,MKMapView。并且實現<MKMapViewDelegate,CLLocationManagerDelegate>
//初始化CLLocationManager,CLLocationManager獲得當前地理坐標
locmanager=[[CLLocationManager?alloc]init];
[locmanager?setDelegate:self];
?//設置精確度
[locmanager?setDesiredAccuracy:kCLLocationAccuracyBest];
[locmanager startUpdatingLocation];
執行完以后,會自動調用代理方法:
轉載于:https://www.cnblogs.com/xyzaijing/p/4047612.html
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的[转] ios学习--openURL的使用方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Fedora 12 环境搭建
- 下一篇: datasci