我使用此代码更改注释的颜色,但在此之后,标题和副标题无法显示,如何保存此问题?
代码是:
- (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation
{
static NSString *defaultPinID = @"LYB";
MKPinAnnotationView *customPinview = (MKPinAnnotationView *)[_mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if ( customPinview == nil ) {
customPinview = [[[MKPinAnnotationView alloc]
initWithAnnotation:from reuseIdentifier:defaultPinID] autorelease];
}
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
if ([[annotation title] isEqualToString:@"the first"]) {
customPinview.pinColor = MKPinAnnotationColorGreen;
}
return customPinview;
}
答案 0 :(得分:2)
在“return customPinview”之前在新行中添加以下代码:
customPinview.canShowCallout = YES;