[轉] ios學習--openURL的使用方法

來源:互聯網
上載者:User

標籤:des   http   io   os   ar   使用   for   sp   on   

openURL的使用方法:
view plaincopy toclipboardprint?
       [[UIApplication sharedApplication] openURL:[NSURL URLWithString:appString]];  
其中系統的appString有:

1.Map    http://maps.google.com/maps?q=Shanghai  
2.Email  mailto://[email protected]  
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://[email protected]"]];
 } 
 
- (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程式內調用Google地圖

使用CLLocationManager類,MKMapView。並且實現<MKMapViewDelegate,CLLocationManagerDelegate>
//初始化CLLocationManager,CLLocationManager獲得當前地理座標
locmanager=[[CLLocationManager alloc]init];

[locmanager setDelegate:self];
 //設定精確度
[locmanager setDesiredAccuracy:kCLLocationAccuracyBest];

[locmanager startUpdatingLocation];
執行完以後,會自動調用代理方法:

[轉] ios學習--openURL的使用方法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.