【发布时间】:2014-03-22 01:37:35
【问题描述】:
当用户点击地图注释中的标注时,我正在尝试打开详细视图控制器。
我创建了一个名为 myAnnotation 的自定义注释子类,并在其中包含了一个名为 idEmpresa 的属性。
在自定义方法中,我将注释声明如下:
double latitud = [[[categorias objectAtIndex:i] objectForKey:@"latitud"] doubleValue];
double longitud = [[[categorias objectAtIndex:i] objectForKey:@"longitud"]doubleValue];
CLLocationCoordinate2D lugar;
lugar.latitude = latitud;
lugar.longitude = longitud;
NSString *nombre = [[categorias objectAtIndex:i] objectForKey:@"titulo"];
CLLocationCoordinate2D coordinate3;
coordinate3.latitude = latitud;
coordinate3.longitude = longitud;
myAnnotation *annotation3 = [[myAnnotation alloc] initWithCoordinate:coordinate3 title:nombre ];
annotation3.grupo = 1;
int number = [[[categorias objectAtIndex:i] objectForKey:@"idObjeto"] intValue];
annotation3.idEmpresa = number;
NSLog(@"ESTA ES LA ID DE LA EMPRESA %d",number);
[self.mapView addAnnotation:annotation3];
你可能会看到注解有一个属性annotation3.idEmpresa。
然后,在calloutAccessoryControlTapped 方法中,我需要访问该属性。我知道如何访问该方法中的注释标题和副标题:
NSString *addTitle = [[view annotation] title ];
NSString *addSubtitle = [[view annotation] subtitle ];
但它不适用于属性 idEmpresa
NSString *addTitle = [[view annotation] title ];
【问题讨论】:
标签: ios mkmapview mkannotation mkannotationview