【问题标题】:Annotation title cannot be shown after change the pincolor更改pincolor后无法显示注释标题
【发布时间】:2012-04-23 15:40:44
【问题描述】:

我用这段代码改变了注解的颜色,但是之后标题和副标题就不能显示了,我该如何保存这个问题?

代码是:

- (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation 
{   
  static NSString *defaultPinID = @"LYB"; 
    MKPinAnnotationView *customPinview = (MKPinAnnotationView *)[_mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID]; 
    if ( customPinview == nil ) {
        customPinview = [[[MKPinAnnotationView alloc] 
                    initWithAnnotation:from reuseIdentifier:defaultPinID] autorelease]; 
    }
    if ([annotation isKindOfClass:[MKUserLocation class]])
        return nil;
    if ([[annotation title] isEqualToString:@"the first"]) {
        customPinview.pinColor = MKPinAnnotationColorGreen;
    }
    return customPinview;
}

【问题讨论】:

    标签: ios annotations mkmapview mkpinannotationview


    【解决方案1】:

    在“return customPinview”之前的新行中添加以下代码:

    customPinview.canShowCallout = YES;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-03
      • 2023-03-15
      • 1970-01-01
      • 1970-01-01
      • 2021-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多