標籤:des style blog http color io os 使用 ar
1、修改info 新增Key:NSLocationAlwaysUsageDescription和NSLocationWhenInUseUsageDescription,這兩個Key的值將分別用於描述應用程式始終使用和使用期間使用定位的說明,這些說明將顯示在使用者佈建中。info新增鍵值對如下:
應用程式說明參見:
2、CLLocationManager初始化iOS8CLLocationManager新增執行個體方法requestWhenInUseAuthorization和requestAlwaysAuthorization,需要在初始化時根據需要調用。
if([CLLocationManager locationServicesEnabled]){ self.locationManage = [[[CLLocationManager alloc] init] autorelease]; self.locationManage.delegate = self; self.locationManage.distanceFilter = 200; self.locationManage.desiredAccuracy = kCLLocationAccuracyBestForNavigation;//kCLLocationAccuracyBest; if (SYSTEM_VERSION >= 8.0) { //使用期間 [self.locationManage requestWhenInUseAuthorization]; //始終 //or [self.locationManage requestAlwaysAuthorization] } }
3、代理新增下面的代理方法:
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status{ switch (status) { case kCLAuthorizationStatusNotDetermined: if ([self.locationManage respondsToSelector:@selector(requestAlwaysAuthorization)]) { [self.locationManage requestWhenInUseAuthorization]; } break; default: break; }}
iOS8定位問題解決方案