同一地图视图中的多个不同的自定义 Pin 图
这是我的问题......
我有一个地图视图,我用几个自定义引脚填充视图。 我会在我的地图视图中使用不同的自定义引脚。
我尝试过使用 IF 条件但不起作用。 我不明白被调用的方法是如何工作的。
按照代码操作。 Vi allego il codice。
//Customization of my pins
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation(id<MKAnnotation>)annotation{
static NSString *identifier = @"";
MKAnnotationView *pin = [ mappa dequeueReusableAnnotationViewWithIdentifier:identifier ];
//OLD COORDINATES
if(newcoordinate == FALSE){
pin = [[[ MKAnnotationView alloc ] initWithAnnotation:annotation reuseIdentifier:identifier ]autorelease];
pin.image = [ UIImage imageNamed:@"old.png" ]
}
// NEW COORDINATES
else ( newcoordinate == TRUE){
pin = [[[ MKAnnotationView alloc ] initWithAnnotation:annotation reuseIdentifier:identifier ]autorelease];
pin.image = [ UIImage imageNamed:@"new.png" ];
}
pin.canShowCallout = YES;
//CALLOUT INFO
UIImage *image = [UIImage imageNamed:@"informations.png"];
UIImageView *imgView = [[[UIImageView alloc] initWithImage:image]autorelease];
pin.leftCalloutAccessoryView = imgView;
pin.annotation = annotation;
return pin;}
结果是...同一个地图视图中的多个引脚,但具有相同的自定义。 :/
谢谢。
This is my question....
I have a mapView and i fill the view with several custom pins.
I would different custom pins in my mapView.
I have tried with an IF condition but don't work.
I don't understand how the called to method works.
Follow the code.
Vi allego il codice.
//Customization of my pins
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation(id<MKAnnotation>)annotation{
static NSString *identifier = @"";
MKAnnotationView *pin = [ mappa dequeueReusableAnnotationViewWithIdentifier:identifier ];
//OLD COORDINATES
if(newcoordinate == FALSE){
pin = [[[ MKAnnotationView alloc ] initWithAnnotation:annotation reuseIdentifier:identifier ]autorelease];
pin.image = [ UIImage imageNamed:@"old.png" ]
}
// NEW COORDINATES
else ( newcoordinate == TRUE){
pin = [[[ MKAnnotationView alloc ] initWithAnnotation:annotation reuseIdentifier:identifier ]autorelease];
pin.image = [ UIImage imageNamed:@"new.png" ];
}
pin.canShowCallout = YES;
//CALLOUT INFO
UIImage *image = [UIImage imageNamed:@"informations.png"];
UIImageView *imgView = [[[UIImageView alloc] initWithImage:image]autorelease];
pin.leftCalloutAccessoryView = imgView;
pin.annotation = annotation;
return pin;}
The result is... several pin in the same mapView but with the same customization.
:/
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
已解决。
我在 MyAnnotation 类中添加了一个新属性:
今天我了解了这些属性是什么。
SOLVED.
I have added a new property in MyAnnotation class:
Today i have learned what are the properties.