使用错误== 0调用mapViewDidFailLoadingMap委托方法 [英] mapViewDidFailLoadingMap delegate method gets called with error == 0
问题描述
在我的viewcontroller中,我创建一个MKMapView对象.我将委托设置为self,并在ViewController中实现:
In my viewcontroller, I create a MKMapView object. I set the delegate to self, and in the ViewController, I implemented:
- (void)mapViewDidFailLoadingMap:(MKMapView *)mapView withError:(NSError *)error
该方法被调用,但是在调试器中,我看到error
的值为0x0
This method gets called, but in the debugger, I see that error
has the value 0x0
这发生在设备和模拟器中.
This happens on the device, and in the simulator.
我需要错误代码,因为我想为无法访问Internet的情况提供一条消息,同时忽略诸如(来自API文档)这样的情况:如果在先前请求的同时出现了对其他地图图块的请求瓷砖仍在等待中"(对我来说这似乎不是失败)
I need the error code, as I want to give a message for the case where internet access is unavailable, while ignoring the cases like (from the API doc) "if a request for additional map tiles comes in while a previous request for tiles is still pending" (which doesn't seem like a failure to me)
推荐答案
我刚刚做了一些测试.
I just did some testing.
- Internet已关闭:[错误描述] =错误域= NSURLErrorDomain代码= -1009 UserInfo = 0x46c6120没有Internet连接"
- 滚动太快:错误= nil(0x0)
我不知道是否还有其他错误情况,但是至少您可以区分Internet连接错误(在这种情况下,我将显示警报)和滚动太快的情况(在这种情况下,我只会忽略它.
I don't know if there are any other error conditions, but at least you can discriminate between an internet conneciton error (in which case I will display an alert) and the scrolling too quickly case, in which I'll just ignore it.
这篇关于使用错误== 0调用mapViewDidFailLoadingMap委托方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!