我在我的应用程序中使用了这个例子,
http://spitzkoff.com/craig/?p=81
但是当我点击附件控件时,它没有调用/触发calloutAccessoryControlTapped。
这是我的代码。
- (void)viewDidLoad {
MapAnnotation *annotation = nil;
annotation = [[MapAnnotation alloc] initWithCoordinate:[[trackPointsArray objectAtIndex:trackPointsArray.count - 2] coordinate]];
[mapView addAnnotation:annotation];
[super viewDidLoad];
}
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
MKAnnotationView *annotationView = nil;
// start pin
static NSString *StartPinIdentifier = @"StartPinIdentifier";
MKPinAnnotationView *startPin = [annotationView dequeueReusableCellWithIdentifier:StartPinIdentifier];
if (startPin == nil) {
startPin = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:StartPinIdentifier] autorelease];
startPin.animatesDrop = YES;
startPin.pinColor = MKPinAnnotationColorGreen;
startPin.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
startPin.canShowCallout = YES;
startPin.enabled = YES;
UIImage *image = [UIImage imageNamed:@"location.png"];
UIImageView *imgView = [[UIImageView alloc] initWithImage:image];
startPin.leftCalloutAccessoryView = imgView;
}
annotationView = startPin;
return annotationView;
}
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
NSLog(@"calloutAccessoryControlTapped");
}
我一直在努力解决这个问题,似乎很多人也遇到了同样的问题。 任何帮助,将不胜感激。感谢
答案 0 :(得分:0)
问题解决了! 我的另一种观点是阻止了mapview。 [self setUserInteractionEnabled:NO];