我无法显示注释标题,如下图所示。第一张图片很好地表示了价值;另一方面,一旦值上升到三位数,则标题显示三个点,如第二张图片所示。我想知道如何解决这个问题。任何想法都会受到欢迎!提前非常感谢,不胜感激!我刚刚把我的代码放在这里供参考!
- (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation {
MKAnnotationView *pinView=nil;
if(![annotation isKindOfClass:[Annotation class]]) // Don't mess user location
return nil;
static NSString *defaultPinID = @"StandardIdentifier";
pinView = (MKAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if (pinView == nil){
pinView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID];
}
if ([annotation isKindOfClass:[Annotation class]]) {
Annotation *a = (Annotation *)annotation;
pinView.image = [ZSPinAnnotation pinAnnotationWithColor:a.color];
pinView.annotation = a;
pinView.enabled = YES;
pinView.centerOffset=CGPointMake(6.5,-16);
pinView.calloutOffset = CGPointMake(-11,0);
}
pinView.canShowCallout = YES;
UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton setTitle:annotation.title forState:UIControlStateNormal];
[pinView setRightCalloutAccessoryView:rightButton];
pinView.leftCalloutAccessoryView = [[UIView alloc] init];
pinView.leftCalloutAccessoryView=nil;
return pinView;
}
我的 showCallout 标题在以下代码中更新:
NSNumber *attr2=[attr valueForKey:@"ozone_level"];
annotation.title=[NSString stringWithFormat:@"Ozone Level:%@",[attr2 stringValue]];