这是我的问题。由于我的viewForAnnotation方法,我创建了一个带按钮的红色图钉。但是按钮没有显示。这是我的代码:
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
//static NSString *defaultPinID = @"identifier";
MKPinAnnotationView *pinView = (MKPinAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:@"identifier"];
if ( pinView == nil )
{
pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"identifier"];
pinView.enabled = YES;
pinView.pinColor=MKPinAnnotationColorRed;
pinView.canShowCallout = YES;
UIButton *btn = [UIButton buttonWithType:UIButtonTypeInfoDark];
[btn setTitle:@"test" forState:UIControlStateNormal];
pinView.rightCalloutAccessoryView = btn;
}
else
{
pinView.annotation = annotation;
}
pinView.annotation = annotation;
return pinView;
}
有人可以帮助我吗?
答案 0 :(得分:0)