I use MKPinAnnotationView in MKMapView, the title and subtitles are displayed fine , but rightCalloutAccessoryView not displayed.
I tried google many times but havenβt been able to show it yet. My code is below.
- (void)addAnnotation { CLLocationCoordinate2D theCoordinate = self.location.coordinate; MapAnnotation *annotation = [[MapAnnotation alloc] initWithCoordinate:theCoordinate]; annotation.title = @"Pin"; annotation.subtitle = @"More information"; [self.mapView addAnnotation:annotation]; } - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation { if ([annotation isKindOfClass:[MapAnnotation class]]) { static NSString *reuseIdentifier = @"MyMKPinAnnotationView"; MKPinAnnotationView *annotationView = (MKPinAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:reuseIdentifier]; if (!annotationView) { annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:reuseIdentifier]; annotationView.pinColor = MKPinAnnotationColorRed; annotationView.enabled = YES; annotationView.canShowCallout = YES; annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; } else { annotationView.annotation = annotation; } } return nil; }
Please note that the title and subtitles may be displayed.
Thanks in advance.
source share