未调用位置管理器didUpdateLocations。
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
[self.locationManager startUpdatingLocation];
用于回叫,我正在使用此委托方法
- (void)locationManager:(CLLocationManager )manager didUpdateLocations:(NSArray )locations
{
NSLog(@"%@", [locations lastObject]);
}
导入框架CoreLocation
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])
{
[self.locationManager requestWhenInUseAuthorization];
}
[self.locationManager startUpdatingLocation];
在iOS8及更高版本中,您必须通过调用requestAlwaysAuthorization或requestWhenInUseAuthorization来请求权限以明确使用位置服务。