1
在我的MapView中有多個annotationView,每個都有自己的圖像,有時候當我按下圖像時,它會消失,如果不重新加載viewController,它將不會再回來。爲什麼會發生?爲什麼當我按下AnnotationView有時圖像消失?
- (MKAnnotationView *)mapView:(MKMapView *)mapview viewForAnnotation:(id
<MKAnnotation>)annotation
{
if ([annotation isKindOfClass:[AnnotationView class]]) {
return nil;
}
if ([annotation isKindOfClass:[AnnotationCustom class]]){
static NSString* AnnotationIdentifier = @"AnnotationIdentifier";
MKPinAnnotationView *annotationView = (MKPinAnnotationView*) [mapView
dequeueReusableAnnotationViewWithIdentifier:AnnotationIdentifier];
annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:AnnotationIdentifier];
if ([self.nameTable isEqualToString:@"Movies"]){
if(UI_USER_INTERFACE_IDIOM()== UIUserInterfaceIdiomPhone){
annotationView.image = [UIImage imageNamed:@"iphone_movies.png"];
}else{
annotationView.image = [UIImage imageNamed:@"ipad_movies.png"];
}
}else if ([self.nameTable isEqualToString:@"Food_Drink"]){
if(UI_USER_INTERFACE_IDIOM()== UIUserInterfaceIdiomPhone){
annotationView.image = [UIImage imageNamed:@"iphone_foodDrink.png"];
}else{
annotationView.image = [UIImage imageNamed:@"ipad_foodDrink.png"];
}
}else if (......){
//same procedure for all annotationView
}
UIButton *detailButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
annotationView.rightCalloutAccessoryView=detailButton;
annotationView.canShowCallout = YES;
annotationView.draggable = YES;
return annotationView;
}
東西不見了?
它仍然發生 –
能否請您編輯您原來的職位,包括在整個代碼viewForAnnotation方法? – NikosM