0

我正在使用MKReverseGeocoder在我的 iPhone 应用程序中查找当前位置。现在有一天,该应用程序不应该找到当前位置。当我解决问题时,我发现来自- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error委托的以下错误响应。错误信息是,

SourceCache/ProtocolBuffer/ProtocolBuffer-92/Runtime/PBRequester.m:687 server returned error: 503
2012-07-10 12:21:29.773 Dial25[3046:707] didFailWithError:- Error Domain=NSURLErrorDomain Code=-1011 "The operation couldn’t be completed. (NSURLErrorDomain error -1011.)" UserInfo=0x264090 {PBHTTPStatusCode=503}

我使用了谷歌并找到了添加委托的答案,[geoder autorelease];didFailWithError:我的应用程序仍然不应该找到当前位置。

-(void)startFindLocationService 
{
    NSLog(@"Starting Location Services");
    CLLocationManager *locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self;
    locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
    locationManager.distanceFilter = 20.0f;
}

-(void)findAddressByLatLong:(CLLocation *)currentLocation
{
    CLLocationCoordinate2D locationToLookup = currentLocation.coordinate;

    MKReverseGeocoder  *reverseGeocoder = [[MKReverseGeocoder alloc] initWithCoordinate:locationToLookup];
    reverseGeocoder.delegate = self;
    [reverseGeocoder start];
}

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error
{
    NSLog(@"Error: %@", [error description]);
    [geocoder cancel];
    geocoder.delegate = nil;    
    [geocoder autorelease];
}

谁能帮我解决这个问题?提前致谢。

4

1 回答 1

0

我正在尝试更多地了解自己的地理编码,并且可能已经找到了一些其他有用的参考资料。

  1. 自 iOS 5 以来,几个 MKReverseGeocoder 类方法已被弃用:http: //developer.apple.com/library/ios/#documentation/MapKit/Reference/MKReverseGeocoder_Class/DeprecationAppendix/AppendixADeprecatedAPI.html#//apple_ref/doc/uid/TP40008323-附录A

  2. 早在 2010 年就有问题,谷歌只在一天中的特定时间响应 MKReverseGeocoder 请求。我不知道这是否与您的问题有关,但可能与 Apple 弃用这些方法的原因有关。 http://blog.aribraginsky.com/2009/12/curious-case-of-mkreversegeocoder.html

  3. 通过切换到 CLGeocoder 查看 Rohan Kapur 对 MKReverseGeocoder 错误的解决方案: 在单例类 (ARC) 中使用 MKReverseGeocoder

希望这可以帮助!

于 2012-08-02T21:31:53.097 回答