reverseGeocodeLocation的完成处理程序没有被调用

时间:2016-11-11 10:58:07

标签: ios objective-c reversegeocodelocation

我已编写代码以获取用户的当前位置,如下所示 -

-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations{
CLLocation *currentLocation=[locations lastObject];
if (currentLocation!=nil) {
    _cityTextField.text=[NSString stringWithFormat:@"%f",currentLocation.coordinate.latitude];
    _locationTextField.text=[NSString stringWithFormat:@"%f",currentLocation.coordinate.longitude];
}

[geoCoder reverseGeocodeLocation:currentLocation completionHandler:^(NSArray<CLPlacemark *> *placeMarks, NSError *error){
    if (error==nil && [placeMarks count]>0) {
        placeMark=[placeMarks lastObject];
        _cityTextField.text=[NSString stringWithFormat:@"%@",placeMark.administrativeArea];
        _locationTextField.text=[NSString stringWithFormat:@"%@",placeMark.locality];
        [location stopUpdatingLocation];
    }
    else{
        NSLog(@"%@",error.debugDescription);
    }
}];

我能够在文本字段中获取纬度和经度的值。但是当指针到达reverseGeocodeLocation方法时,它不会执行完成处理程序并直接到达最后。任何人都可以指出我的错误。感谢

0 个答案:

没有答案
相关问题