在我的应用程序中,我使用MKMapView在地图视图上显示一些位置.它显示地图很好.但从昨天开始它只显示网格而不显示地图,当我添加委托方法时,它会在mapviewdidfiailtoload中显示.
我使用以下代码
// MapView类
myMapView=[[MKMapView alloc] initWithFrame:CGRectMake(0,gameNameLabel.frame.size.height, 320, 181)]; myMapView.mapType=MKMapTypeStandard; myMapView.delegate=self; LocationModel *loc=presentGame.location; NSArray *cordinates=[loc.geoCordinates componentsSeparatedByString:@","]; CLLocationCoordinate2D zoomLocation; zoomLocation.latitude = [[cordinates objectAtIndex:0] doubleValue]; zoomLocation.longitude= [[cordinates objectAtIndex:1] doubleValue]; MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, 0.5*METERS_PER_MILE, 0.5*METERS_PER_MILE); // 3 MKCoordinateRegion adjustedRegion = [myMapView regionThatFits:viewRegion]; // 4 [myMapView setRegion:adjustedRegion animated:YES]; [scroll addSubview:myMapView]; Place *pin = [[Place alloc] init]; pin.name = loc.gameLocation; pin.latitude = [[cordinates objectAtIndex:0] doubleValue]; pin.longitude = [[cordinates objectAtIndex:1] doubleValue]; PlaceMark* Place1 = [[PlaceMark alloc] initWithPlace:pin]; Place1.tagg=1; [myMapView addAnnotation:Place1]; //end of mapview
- (MKAnnotationView*)mapView:(MKMapView*)mapView1 viewForAnnotation:(id)annotation {
static NSString *identifier = @"PlaceMark"; if ([annotation isKindOfClass:[PlaceMark class]]) { MKPinAnnotationView *annotationView = (MKPinAnnotationView *) [mapView1 dequeueReusableAnnotationViewWithIdentifier:identifier]; annotationView.tag=[mapView1.annotations count]; if (annotationView == nil) { annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier]; } else { annotationView.annotation = annotation; } annotationView.enabled = YES; annotationView.canShowCallout = YES; return annotationView; } return nil;
}
METERS_PER_MILE定义为1609.344,我在.h文件中设置了委托.
一切都工作正常,但现在只显示网格,显示Pin atleaset