MapKit注释自定义图像不起作用

时间:2012-05-23 16:18:54

标签: ios annotations mapkit

我在MapKit注释上遇到自定义图像问题。构建一个我正在执行相同测试的示例项目,它可以正常工作(尽管放置效果和自定义图像不起作用)。

但是当我在地图视图项目中使用完全相同的功能时,自定义图像不会出现。我注意到颜色引脚更改功能MKPinAnnotationColorPurple也不起作用。是否有可能取决于某些项目属性?

代码是:

-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
    static NSString *identifier = @"MyLocation";   

    if ([annotation isKindOfClass:[MyLocation class]]) {

        MKPinAnnotationView *annotationView = (MKPinAnnotationView *) [_mapView dequeueReusableAnnotationViewWithIdentifier:identifier];

        if (annotationView == nil) {
            annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
        } else {
            annotationView.annotation = annotation;
        }
        annotationView.enabled = YES;
        annotationView.animatesDrop=    NO;
        annotationView.image=[UIImage imageNamed:@"arrest.png" ];//here we use a nice image instead of the default pins


        annotationView.canShowCallout = YES;
        UIButton *btnDetails = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        //[btnDetails addTarget:self action:@selector(prova) forControlEvents:UIControlEventTouchUpInside]; 

        annotationView.rightCalloutAccessoryView=btnDetails;

        return annotationView;
    }

    return nil;
}

UIButtonTypeDetailDisclosure也不会出现(在其他项目中)。

0 个答案:

没有答案
相关问题