iOS8 定位失敗問題


iOS7升級到iOS8後,百度地圖 iOS SDK 中的定位功能不可用,給廣大開發者帶來了不便,在此向你們分享一個方法來解決次問題。(官方的適配工做還在進行中,不久將會和廣大開發者見面)blog

 

一、在info.plist中加入:ip

NSLocationAlwaysUsageDescription=YES
NSLocationWhenInUseUsageDescription=YES開發

 

二、在調用百度地圖 iOS SDK 定位以前,先運行以下代碼:it

if ([[UIDevice currentDevice].systemVersion floatValue] >= 8) {
    //因爲IOS8中定位的受權機制改變 須要進行手動受權
    CLLocationManager  *locationManager = [[CLLocationManager alloc] init];
    //獲取受權認證
    [locationManager requestAlwaysAuthorization];
    [locationManager requestWhenInUseAuthorization];
}
相關文章
相關標籤/搜索