0
-(MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
    MKPinAnnotationView *MyPin=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"User"];
    UIImageView *myCustomImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@""]];
    MyPin.leftCalloutAccessoryView = myCustomImage;
}

我想将注释的 leftCalloutAccessoryView 设置为直到运行时才知道的特定图像。我在创建的每个单独注释中定义了所需的特定图像,但是如何在此函数中访问特定注释的类,以便我可以相应地设置 myCustomImage?

4

2 回答 2

0

使用它,然后您可以使用 temp 访问您班级的某些成员。

Pin *temp = (Pin *)annotation;
于 2014-08-22T22:43:08.923 回答
0

这应该是您正在寻找的:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
    if ([annotation isKindOfClass:[someClassHere class]]) {

    }
}
于 2014-08-22T21:55:04.657 回答