【发布时间】:2015-05-27 07:51:18
【问题描述】:
我正在使用目标 c 使用 Mapkit,我想在地图上显示“错误警报”。 当互联网工作时,它工作正常,但当互联网工作不正常时,它会自动显示在日志“请求超时”而不调用“mapViewDidFailLoadingMap”委托方法。
代码在这里:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
mapView.delegate=self;
mapView.showsUserLocation = YES;
[mapView setMapType:MKMapTypeStandard];
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:YES];
//[self activeCLLocation];
}
-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
NSLog(@"user latitude==>%f",userLocation.location.coordinate.latitude);
NSLog(@"user longitude==>%f",userLocation.location.coordinate.longitude);
}
-(void)mapViewDidFailLoadingMap:(MKMapView *)mapView withError:(NSError *)error
{
NSLog(@"error map===>%@",error.description);
}
-(void)mapView:(MKMapView *)mapView didFailToLocateUserWithError:(NSError *)error
{
NSLog(@"error loc===>%@",error.description);
}
显示错误:
2015-05-27 12:51:57.624 EventLocator[1262:160081] 无法确定 当前国家代码:Error Domain=NSURLErrorDomain Code=-1001 "The 请求超时。” UserInfo=0x19d80290 {NSErrorFailingURLStringKey=http://gsp1.apple.com/pep/gcc, NSErrorFailingURLKey=http://gsp1.apple.com/pep/gcc, NSLocalizedDescription=请求超时。, NSUnderlyingError=0x17e877a0 "请求超时。"}
【问题讨论】:
标签: ios objective-c iphone ipad ios8