jbu*_*s20 25 iphone core-location mapkit ios clgeocoder
我的应用程序中有一个搜索栏,用户可以输入一个地址,它会产生地理编码结果.根据以下代码,结果将根据用户类型进行更新:
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
...
if (self.geocoder.geocoding) [self.geocoder cancelGeocode];
[self.geocoder geocodeAddressString:searchText completionHandler:^(NSArray *placemarks, NSError *error) {
if (error != nil) {
NSLog(@"ERROR during geocode: %@", error.description);
return;
}
//update the view
}];
}
Run Code Online (Sandbox Code Playgroud)
这适用于用户输入搜索字段的前几个字符.但是,在用户重复输入更多字符后,地理编码器开始出现以下错误(我知道这意味着网络存在问题):
ERROR during geocode: Error Domain=kCLErrorDomain Code=2 "The operation couldn’t be completed. (kCLErrorDomain error 2.)"
Run Code Online (Sandbox Code Playgroud)
在重新加载整个ViewController之前,地理编码器不会再次运行.为什么会发生这种情况,我该怎么做才能解决它?
归档时间: |
|
查看次数: |
15326 次 |
最近记录: |