The problem is that the layout of the leader view is not recounted when the name changes. Maybe you should specify an error report for this.
To force a relay, you can deselect and programmatically select the annotation if the leader is visible. It is not animated, but changes the width of the leader:
NSNumber *attr2=[attr valueForKey:@"ozone_level"]; annotation.title=[NSString stringWithFormat:@"Ozone Level:%@",[attr2 stringValue]]; if ([self.mapView viewForAnnotation:annotation] != nil) { NSArray *selectedAnnotations = self.mapView.selectedAnnotations; if ((selectedAnnotations != nil) && ([self.mapView.selectedAnnotations indexOfObject:annotation] != NSNotFound)) { [self.mapView deselectAnnotation:annotation animated:NO]; [self.mapView selectAnnotation:annotation animated:NO]; } }
You should also delete this line, since the annotation header is used anyway as a text label in the annotation:
[rightButton setTitle:annotation.title forState:UIControlStateNormal]
UPDATE:
The @detunized solution provides animation work. Instead of creating an unnecessary UIView, you can better remove and re-add the button view:
NSNumber *attr2=[attr valueForKey:@"ozone_level"]; annotation.title=[NSString stringWithFormat:@"Ozone Level:%@",[attr2 stringValue]]; MKAnnotationView *annotationView = [self.mapView viewForAnnotation:annotation];
source share