我正在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
都是指向的,但它们不显示标题。是什么原因?请帮我找。