MKPinAnnotationView rightCalloutAccessoryView does not send calloutAccessoryControlTapped on iOS7

I am trying to update one of my applications on iOS7. The problem is that on mine MKMapView, when I click on the output, it shows Callout, but when I click on it , rightCalloutAccessoryViewit no longer sends a callback to the delegate. Thus, I can no longer put forward a detailed view.

It worked great on iOS6, no longer works on iOS7.

Here is the relevant piece of code:

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
    if ([annotation isKindOfClass:[MKUserLocation class]]) {
        return nil;
    }
    NSString * annotationIdentifier = nil;
    if ([annotation isKindOfClass:VPStation.class]) {
        annotationIdentifier = @"stationAnnotationIdentifier";
    }
    if (!annotation) {
        return nil;
    }
    MKPinAnnotationView * annotationView = [(MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier] retain];
    if(annotationView == nil) {
        annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:annotationIdentifier];
        annotationView.canShowCallout = YES;
        annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        annotationView.image = [UIImage imageNamed:@"MyAnnotationPin"];
        annotationView.centerOffset = CGPointMake(-10.0f, 0.0f);
    }
    annotationView.annotation = annotation;

    return [annotationView autorelease];
}

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
    if ([view.annotation isKindOfClass:VPStation.class]) {
        VPTotalDetailViewController * detailVC = [[VPTotalDetailViewController alloc] initWithStation:(VPStation *)view.annotation
                                                                                      andUserLocation:self.mapView.userLocation.coordinate];
        [self.navigationController pushViewController:detailVC animated:YES];
        [detailVC release];
    }
}

According MKAnnotationViewto the class reference:

UIControl, . UIControl, .

- , UIView, detailViewController? , Apple ? , , ?

+4
1

, , UIGestureRecognizer, MKMapView ( , , , - ), touch, calloutAccessoryControl. , iOS6 iOS7. , ( ) UIGestureRecognizerDelegate:

#pragma mark - UIGestureRecognizerDelegate
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
    if ([touch.view isKindOfClass:[UIControl class]]) {
        return NO;
    }
    return YES;
}
+12

Source: https://habr.com/ru/post/1502644/


All Articles