我設置標題兩個MKAnnotationView
:MKAnnotationView不顯示標題
-(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:
(id <MKAnnotation>)annotation
{
if(([annotation isKindOfClass:[Test_flag class]]))
{
MKAnnotationView *pinView = nil;
if(annotation != mapView.userLocation)
{
static NSString *defaultPinID = @"PinId1";
pinView = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if (pinView == nil) pinView = [[[MKAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:@"pin1"] autorelease];
pinView.canShowCallout = YES;
pinView.animatesDrop = YES;
[pinView setImage:[UIImage imageNamed:@"flg.png"]];
[pinView setSelected:YES animated:YES];
}
else
{
[mapView.userLocation setTitle:@"I am here"];
}
return pinView;
}
else if(([annotation isKindOfClass:[Distance1 class]]))
{
MKAnnotationView *pinView = nil;
if(annotation != mapView.userLocation)
{
static NSString *defaultPinID = @"PinId4";
pinView = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if (pinView == nil) pinView = [[[MKAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:@"pin4"] autorelease];
pinView.canShowCallout = YES;
[pinView setImage:[UIImage imageNamed:@"Circle_Grey.png"]];
[pinView setSelected:YES animated:YES];
}
else
{
[mapView.userLocation setTitle:@"I am here"];
}
return pinView;
}
當我觸摸地圖,無論是MKAnnotationView
被指出,但他們不顯示標題。是什麼原因?請幫我找。
按照SO回答http://stackoverflow.com/questions/5589181/displaying-pin-with-title-annotation-once-map-loads – Deepesh