【问题标题】:GeoLocation to find a coordinate getting kCLErrorDomain error 8GeoLocation 查找坐标得到 kCLErrorDomain 错误 8
【发布时间】:2015-01-03 09:43:55
【问题描述】:

我正在实现一个地理定位代码,这意味着我想将一个地址作为一个字符串,然后以 CLCoordinate 的形式返回一个位置。我收到了这个奇怪的错误代码,其他人似乎没有看到。

kCLErrorDomain 错误 8

我没有地图,因为我只想从地址字符串中获取坐标。然后稍后将此坐标用于程序的另一部分。我觉得我错过了什么。感谢您的所有帮助!

  @interface ViewController () <CLLocationManagerDelegate, UISearchBarDelegate>

  @property (strong, nonatomic) IBOutlet UISearchBar *BarSearch;

 @property (strong,nonatomic) CLGeocoder *Geocoder;
 @property (strong,nonatomic) CLLocationManager *locationManager;

 @end

 @implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];

self.locationManager = [[CLLocationManager alloc]init];
    self.locationManager.delegate = self;

//Check to see if they have Authorization to use to use location servieces
if ([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)])
{
    [self.locationManager requestAlwaysAuthorization];
}

[self.locationManager startUpdatingLocation];

//Setup UISearch Bar
self.BarSearch.delegate=self;

}

程序确实进入了这个方法,但只是返回这个错误: kCLErrorDomain 错误 8

  -(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{


self.Geocoder = [[CLGeocoder alloc]init];

[self.Geocoder geocodeAddressString:@"Springfield, MA" completionHandler:^(NSArray* placemarks, NSError* error){
    if (!error) {

        for (CLPlacemark* aPlacemark in placemarks)
        {
            NSLog(@"place--%@", [aPlacemark locality]);
            NSLog(@"lat--%f\nlong--   %f",aPlacemark.location.coordinate.latitude,aPlacemark.location.coordinate.longitude);
        }
    }
    else{

        NSLog(@"error--%@",[error localizedDescription]);
    }
}];

}

【问题讨论】:

    标签: ios objective-c geolocation core-location


    【解决方案1】:

    愚蠢的错误,但只需重新启动 iOS 模拟器,问题就解决了。

    【讨论】:

      【解决方案2】:

      您是否已将此密钥添加到您的信息列表中:NSLocationAlwaysUsageDescription

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-03-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-07-18
        • 2016-07-23
        • 1970-01-01
        相关资源
        最近更新 更多