如何处理 iOS 4.3 中的 MKReverseGeocoder / PBHTTPStatusCode=503 错误?
从 iOS 4.3 (GM Seed 10M2518) 开始,我在使用 MKReverseGeocoder
时遇到崩溃。 reverseGeocoder:didFailWithError:
经常被调用并出现这样的错误:
Error Domain=NSURLErrorDomain Code=-1011 “操作无法完成。(NSURLErrorDomain 错误 -1011。)” UserInfo =0x339900 {PBHTTPStatusCode=503}
应用程序在这些时刻往往会崩溃。 在之前的 iOS 版本中,情况并非如此。
有什么想法发生了什么吗?
Since iOS 4.3 (GM Seed 10M2518) I'm getting crashes when using MKReverseGeocoder
. reverseGeocoder:didFailWithError:
gets called with an error like this quite often:
Error Domain=NSURLErrorDomain Code=-1011 "The operation couldn’t be completed. (NSURLErrorDomain error -1011.)" UserInfo=0x339900 {PBHTTPStatusCode=503}
The app tends to crash at these moments.
This hasn't been the case in previous versions of iOS.
Any ideas what happened?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
确保失败时不会过早释放反向地理编码器:
将
-(void)reverseGeocoder:(MKReverseGeocoder 中的
为我解决了这个问题。[_reverseGeocoder release]
更改为[_reverseGeocode autorelease]
*)geocoder didFailWithError:(NSError *)errorMake sure you don't release the reverse geocoder prematurely on failure:
Changing
[_reverseGeocoder release]
to[_reverseGeocode autorelease]
in-(void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error
fixed the problem for me.Google 不允许单个设备在 60 秒内多次检索其位置,因此当 (MKReverseGeocoder *)geocoder didFailWithError 时,使用另一种方法(改为 http 请求,需要 JSON)。
它在 4.3.3 (3GS) 上适用于我,并测试了 30-40 次连续检索用户位置而没有崩溃,希望它有帮助!
Google doesn't allow a single device to retrieve its location more than once within 60 sec, hence working with another method (http request instead, JSON needed) when (MKReverseGeocoder *)geocoder didFailWithError.
It works for me on 4.3.3 (3GS) and tested for 30-40 times retrieving user's location consecutively without a crash, hope it helps!
同样的问题,我们检查了各种解决方案,但没有成功。以前的操作系统对 503 响应代码的处理方式有所不同,您可以通过嗅探 iPhone 流量轻松注意到这一点。
依赖 MKReverseGeocoder(如 Gowalla)的应用程序将对 Apple 造成一些压力……所以我预计近期会发布 4.3.1 修补程序。或者 Google 根据 Apple 的要求更改其 SLA。
Same problem here, we checked various solutions and didn't work. The 503 response code is handled differently by the previous OS, you can easily notice that by sniffing the iPhone traffic.
Applications that rely on MKReverseGeocoder (like Gowalla) will make some pressure against Apple ... so I would expect a 4.3.1 hotfix coming these days. Or Google to change their SLA with Apple requests.
根据 zippo77 的回答,我在
-(void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error
中首先将 MKReverseGeocoder 委托设置为 nil 时发现了最佳结果Following on from zippo77's answer, I found best results when setting the MKReverseGeocoder delegate to nil first in
-(void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error
我遇到了同样的问题,即使我的 MKReverseGeocoder 代码遵循 Apple 示例之一(
MKReverseGeocoder 作为全局
autorelease
变量)。此外,该问题仅出现在 iOS 4.3 上(4.0 运行没有问题)。对我来说解决问题的方法是删除
autorelease
部分并仅在视图的dealoc
中释放MKReverseGeocoder
。I had the same issue, even though my
MKReverseGeocoder
code followed one of the Apple examples (MKReverseGeocoder
as a globalautorelease
variable). Also the issue appeared only on iOS 4.3 (4.0 was running no problem).What solved the problem for me was removing the
autorelease
part and releasing theMKReverseGeocoder
only indealoc
of the view.也许您正在地理编码器找到地标之前停止位置管理器。在 didFindPlacemark 中执行此操作或出现错误
Probably you are stoping location manager before geo coder will find placemark. Do it in didFindPlacemark or for error