自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

iPhone開發(fā)應(yīng)用中CoreLocation定位學(xué)習(xí)筆記

移動開發(fā) iOS
本文介紹的是iPhone開發(fā)應(yīng)用中CoreLocation定位的內(nèi)容,iPhone可以使用CoreLocation框架確定他的物理位置,可以利用三種技術(shù)來實(shí)現(xiàn)該功能:GPS,WiFi定位和蜂窩基站三角網(wǎng)定位。

iPhone開發(fā)應(yīng)用中CoreLocation定位學(xué)習(xí)是本文要介紹的內(nèi)容,iPhone可以使用CoreLocation框架確定他的物理位置,可以利用三種技術(shù)來實(shí)現(xiàn)該功能:GPS,WiFi定位和蜂窩基站三角網(wǎng)定位。但在程序中我們只需設(shè)定我們希望的精度級別,由CoreLocation決定采用哪種技術(shù)可以更好的滿足我們的請求。

1、位置管理器

  1. CLLocationManager *locationManager = [[CLLocationManager alloc] init];//創(chuàng)建位置管理器  
  2. locationManager.delegate=self;//設(shè)置代理  
  3. locationManager.desiredAccuracy=kCLLocationAccuracyBest;//指定需要的精度級別  
  4. locationManager.distanceFilter=1000.0f;//設(shè)置距離篩選器  
  5. [locationManager startUpdatingLocation];//啟動位置管理器 

2、位置管理器代理

主要的代理方法有兩個

  1. //確定當(dāng)前位置和位置更新了時調(diào)用這個方法  
  2.  
  3. - (void)locationManager:(CLLocationManager *)manager  
  4. didUpdateToLocation:(CLLocation *)newLocation  
  5.    fromLocation:(CLLocation *)oldLocation  
  6. {  
  7. NSString *latitudeString=[[NSString alloc] initWithFormat:@"%g",newLocation.coordinate.latitude];  
  8. //latitudeLabel.text=latitudeString;  
  9. [latitudeString release];  
  10. NSString *longitudeString=[[NSString alloc] initWithFormat:@"%g",newLocation.coordinate.longitude];  
  11. //longitudeLabel.text=longitudeString;  
  12. [longitudeString release];  
  13. }  
  14. //位置查詢遇到錯誤時調(diào)用這個方法  
  15.  
  16.  (void)locationManager:(CLLocationManager *)manager  
  17.   didFailWithError:(NSError *)error  
  18. {  
  19. NSString *errorType = (error.code == kCLErrorDenied) ?  
  20.    @"Access Denied" : @"Unknown Error";  
  21.    UIAlertView *alert = [[UIAlertView alloc]  
  22.                          initWithTitle:@"Error getting Location"  
  23.                           message:errorType  
  24.                           delegate:nil  
  25.                           cancelButtonTitle:@"Okay"  
  26.                           otherButtonTitles:nil];  
  27.     [alert show];  
  28.     [alert release];  

小結(jié):iPhone開發(fā)應(yīng)用中CoreLocation定位學(xué)習(xí)筆記的內(nèi)容介紹完了,希望本文對你有所幫助。

責(zé)任編輯:zhaolei 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2011-08-09 17:29:29

iPhone文件屏幕

2011-08-08 14:57:46

iPhone Autoreleas Property

2011-08-19 11:10:31

iPhone應(yīng)用

2011-08-09 17:12:30

iPhoneCFRunLoop

2011-08-15 10:06:22

iPhone開發(fā)nib 文件

2011-08-08 10:10:14

iPhone開發(fā) 圖片 方法

2011-08-05 14:48:06

iPhone應(yīng)用 異步隊(duì)列

2011-08-18 10:39:46

iPhone開發(fā)界面

2011-08-08 15:56:18

iPhone 震動 NSUserDefa

2011-08-10 17:37:00

iPhoneASIHTTPRequ

2011-08-15 17:38:48

iPhone開發(fā)調(diào)試工具

2011-07-27 11:14:37

iPhone UITableVie

2011-08-09 14:42:07

iPhonePCM播放器

2011-08-15 17:52:21

iPhone應(yīng)用對象NSString

2011-08-15 18:02:32

iPhone開發(fā)表視圖

2011-08-22 14:12:48

iPhone開發(fā)NSTableView

2011-08-15 11:37:20

iPhone開發(fā)Mask

2011-08-12 14:33:06

iPhone緩存文件

2011-08-15 15:44:46

iPhone開發(fā)PDF

2011-08-18 16:24:44

iPhone開發(fā)圖片
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號