OGeek|极客世界-中国程序员成长平台

标题: ios - 更改pincolor后无法显示注释标题 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 22:39
标题: ios - 更改pincolor后无法显示注释标题

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

代码是:

- (MKAnnotationView *)mapViewMKMapView *)mV viewForAnnotationid <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;
}



Best Answer-推荐答案


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

customPinview.canShowCallout = YES;

关于ios - 更改pincolor后无法显示注释标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10104164/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4