關於升級到iOS8地圖定位問題

轉載http://blog.sina.com.cn/s/blog_8be86ad30102v1r0.html

正確讓ios8定位的方法來了:

1.在Info.plist表裏面添加兩個變量

NSLocationAlwaysUsageDescription

NSLocationWhenInUseUsageDescription

(這兩個字段沒什麼特別的意思,就是自定義提示用戶授權使用地理定位功能時的提示語)

     

2.添加代碼:

CLLocationManager  *locationManager = [[CLLocationManager alloc]init];   

locationManager.delegate = self;    

[locationManager requestAlwaysAuthorization];   

locationManager.desiredAccuracy = kCLLocationAccuracyBest;  

locationManager.distanceFilter = kCLDistanceFilterNone;    

[locationManager startUpdatingLocation];


調用代理:

- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {   

switch (status) {        

case kCLAuthorizationStatusNotDetermined:           

if ([locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) {               

[locationManager requestWhenInUseAuthorization];            

}           

break;        

default:            

break;   

  }

}


3.這樣就可以打開地圖定位功能了!


最近在做基於百度Map定位及路線軌跡的功能!完成後,也發出來供大家學習使用,盡情期待吧~iOS <wbr>關於iOS8地圖定位問題


(後續)

最近手機升級到ios8以上,發現地圖又無法定位了!iOS <wbr>關於iOS8地圖定位問題

各種求救,最後找到解決方法!iOS <wbr>關於iOS8地圖定位問題

ios8對定位做了一些調整,

1.@interface裏:

CLLocationManager *locationManager;

2.locationManager=[[CLLcationManager alloc]init];

  if([[[UIDevice currentDevice]systemVersion]doubleValue]>8.0)

  {

[locationManager requestWhenInUseAuthorization];

  }

[locationManager startUpdatingLocation];


發佈了30 篇原創文章 · 獲贊 0 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章