Question

This not works

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control

Tried add this

  if ([annotation isKindOfClass:[User class]])
     {
         NSString * annotationIdentifier = @"UserAnnotationIdentifier";
         CustomAnnotationView * customAnnotationView = (CustomAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
         if (!customAnnotationView)
         {
             customAnnotationView = [[CustomAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:annotationIdentifier];
             UITapGestureRecognizer *tapGesture =
             [[UITapGestureRecognizer alloc] initWithTarget:self
                                                     action:@selector(calloutTapped:)];
             [customAnnotationView addGestureRecognizer:tapGesture];

and then

    -(void) calloutTapped:(id) sender {
       id<MKAnnotation> annotation = ((MKAnnotationView*)sender.view).annotation;

ERROR: property view not found on object of type __strong id

This works, but not always

 - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
 {
NSLog(@"didSelectAnnotationView\n");

 }

 - (void)mapView:(MKMapView *)mapView didDeselectAnnotationView:(MKAnnotationView *)view
 {
NSLog(@"didDeselectAnnotationView\n");
 }

Where I bad?

Was it helpful?

Solution

Please try this.And make sure you set the MKMapViewDelegate to that class.

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
    {
        if([view isKindOfClass:[myCustomAnnotaionClass class]])
        {
            //your programming logic here
        }
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top