位置管理器didUpdateLocations未被调用。
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
[self.locationManager startUpdatingLocation];
for call back i am using this delegate method
- (void)locationManager:(CLLocationManager )manager didUpdateLocations:(NSArray )locations
{
NSLog(@"%@", [locations lastObject]);
}
答案 0 :(得分:0)
导入框架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来请求显式使用位置服务的权限。