Tôi đã sử dụng ví dụ này trong ứng dụng của tôi,calloutAccessoryControlTapped không gọi/kích hoạt
http://spitzkoff.com/craig/?p=81
nhưng nó không gọi/kích hoạt các calloutAccessoryControlTapped như tôi khai thác các accessorycontrol.
Đây là mã của tôi.
- (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");
}
Tôi đã gặp khó khăn với vấn đề này trong một thời gian, có vẻ như nhiều người cũng gặp vấn đề tương tự. Mọi trợ giúp sẽ được đánh giá cao. Cảm ơn