Cocoa touch MKAnnotationView不显示详图索引

Cocoa touch MKAnnotationView不显示详图索引,cocoa-touch,Cocoa Touch,我正在尝试使用MKMapView显示带有标注编号的pin。我得到了要显示的pin,但我就是不知道如何显示标注 这是我的代码: - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id)annotation { if (annotation == mapView.userLocation) { return nil; } MKPinAnnotationView *pinV

我正在尝试使用MKMapView显示带有标注编号的pin。我得到了要显示的pin,但我就是不知道如何显示标注

这是我的代码:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id)annotation {
    if (annotation == mapView.userLocation) {
        return nil;
    }
    MKPinAnnotationView *pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"Pin"];
    pinView.pinColor = MKPinAnnotationColorGreen;
    [pinView setCanShowCallout:YES];
    pinView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    pinView.animatesDrop = YES;
    [self performSelector:@selector(displayPinCallOutView) withObject:nil afterDelay:0.3];
    return pinView;
}

如果试图在注释添加到地图后立即显示详图索引,则必须在didAddAnnotationViews委托方法中执行此操作:

-(void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views
{
    //Get reference to annotation you want to select...
    //You could search through mapView.annotations array
    //or keep ivar reference to it.
    id<MKAnnotation> annToSelect = ...

    [mapView selectAnnotation:annToSelect animated:YES];
}

从viewForAnnotation方法中删除performSelector。

它不起作用:而且我无法选择pin并显示Callout是否调用了didAddAnnotationViews方法在其中放置NSLog?显示如何设置annToSelect。不确定您所说的“无法选择pin并显示标注”是什么意思。可能是因为标注的标题为空或为零。