標籤:des style http color io os ar for sp
xcode6開啟以前xcode5工程,發現程式不能定位,包括iOS8模擬器,真機都不能定位?代碼經檢查沒有問題,後來尋找蘋果Ios8升級差異策略,發現Ios8對定位處理做了一些調整,工程升級到xcode6編譯時間需要iOS8 要自己寫授權,不然沒許可權定位。修改點如下:
1: 在Info.plist中加入兩個預設沒有的欄位 ,值均設定為YES
NSLocationAlwaysUsageDescription
NSLocationWhenInUseUsageDescription
2:啟動定位代碼[locationManager startUpdatingLocation] 前,需要增加Ios8判斷處理
if ([[[UIDevice currentDevice] systemVersion] doubleValue] > 8.0) {
//設定定位許可權 僅ios8有意義
[locationManager requestAlwaysAuthorization];
}
[locationManager startUpdatingLocation];
3:實現 CLLocationManagerDelegate 代理 - (void)locationManagerCLLocationManager *)manager didChangeAuthorizationStatusCLAuthorizationStatus)status 方法,注意:如不增加該代理方法實現,會導致首次調用定位時候無法彈出 ”程式啟動定位提示框“ 導致定位失敗
#pragma mark - 授權定位
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
NSLog(@"調用代理");
switch (status) {
case kCLAuthorizationStatusNotDetermined:{
if ([locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) {
[locationManager requestWhenInUseAuthorization];
}
}
break;
default:{
}
break;
}
}
xcode6開啟以前工程在Ios8系統無法定位解決方案