我不确定为什么细节披露按钮没有出现在 mapkit 标注上。这是我的代码:
我确保包含在 .h 文件中,然后包含以下方法。标注有效并在地图加载后立即出现。我还确保将委托连接到 Xib 文件中。
- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation
{
MKPinAnnotationView *mapPin = nil;
if(annotation != map.userLocation)
{
static NSString *defaultPinID = @"defaultPin";
mapPin = (MKPinAnnotationView *)[map dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if (mapPin == nil )
{
mapPin = [[MKPinAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:defaultPinID];
mapPin.canShowCallout = YES;
UIButton *disclosureButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[disclosureButton addTarget:self action:@selector(clDetails:) forControlEvents:UIControlEventTouchUpInside];
mapPin.rightCalloutAccessoryView = disclosureButton;
}
else
mapPin.annotation = annotation;
}
return mapPin;
}
- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views
{
id<MKAnnotation> myAnnotation = [self.mapView.annotations objectAtIndex:0];
[self.mapView selectAnnotation:myAnnotation animated:YES];
}
谢谢你的帮助。