2
長按自定義註釋引腳變爲默認紅色引腳。mkmapview中註釋引腳的自定義圖像
- (MKAnnotationView *) mapView:(MKMapView *)mapingView viewForAnnotation:(id <MKAnnotation>) annotation {
MKPinAnnotationView *annView = nil;
if(annotation != mapingView.userLocation)
{
static NSString *defaultPinID = kDEFAULTPINID;
annView = (MKPinAnnotationView *)[mapingView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if (annView == nil)
annView = [[MKPinAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:defaultPinID] ;
annView.canShowCallout = YES;
annView.image = [UIImage imageNamed:@"icon.png"];//sets image for default pin
}
return annView;
}
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKPinAnnotationView *)view
{
if ([[view.annotation title] isEqualToString:@"AnnotationTitle"]) {
view.image = [UIImage imageNamed:@"selected_IconImage.png"];
}
}
只需觸摸註釋針,出現所選圖像。 但是長時間在引腳上自定義圖像恢復爲默認紅色引腳。
如何解決這個問題?
由於它的工作原理。 –