gpt4 book ai didi

ios - GeoLocation 查找坐标获取 kCLErrorDomain 错误 8

转载 作者:行者123 更新时间:2023-11-29 02:31:36 26 4
gpt4 key购买 nike

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

kCLErrorDomain错误8

我这里没有 map ,因为我只想从地址字符串中获取坐标。然后稍后将此坐标用于程序的另一部分。我觉得我失去了一些东西。感谢您的帮助!

  @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 模拟器即可解决问题。

关于ios - GeoLocation 查找坐标获取 kCLErrorDomain 错误 8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26787025/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com