Reputation: 205
I used this code to change the annotation's color,but after that,the title and subtitle can not be showed,how can I save this problem?
The code are:
- (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;
}
Upvotes: 2
Views: 233
Reputation: 1279
Add the following Code in a new line before "return customPinview":
customPinview.canShowCallout = YES;
Upvotes: 2