iOS 8 中的 CLlocationManager 问题

Issue with CLlocationManager in iOS 8

当我使用此代码配置 CLlocationManager 时:

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
if([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) {
    [self.locationManager requestAlwaysAuthorization];
    // Or [self.locationManager requestWhenInUseAuthorization];
}    [self.locationManager startUpdatingLocation];

}

并设置位置委托

#pragma mark - CLLocationManagerDelegate

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
    NSLog(@"didFailWithError: %@", error);
    UIAlertView *errorAlert = [[UIAlertView alloc]
                               initWithTitle:@"Error" message:@"Failed to Get Your Location" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [errorAlert show];
}

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
    NSLog(@"didUpdateToLocation: %@", newLocation);
    CLLocation *currentLocation = newLocation;

    if (currentLocation != nil) {
        self.textLongitude.text = [NSString stringWithFormat:@"%.8f", currentLocation.coordinate.longitude];
        self.textLatitude.text = [NSString stringWithFormat:@"%.8f", currentLocation.coordinate.latitude];
    }
}

不发送授权警报,但 Info.plist 已完成

当转到设置并更改设置 -> 隐私 -> 本地化并更改 "always" 的状态并重新启动应用程序时,此状态是干净的。

NSLocationAlwaysUsageDescription 在 plist 中拼写错误。