如何使用公开按钮从地图本身获取从MKMap中的Mutable Array渲染的注释标题?

时间:2013-11-27 17:54:28

标签: objective-c annotations

我正在使用一个可变数组来渲染地图上的注释,问题是当我点击地图中任何注释中的显示按钮时我无法获得该注释的标题,因为我不知道如何得到它的索引,我想在mapLabel中打印...但我找不到这个注释的索引

以下是代码:

-(MKAnnotationView *) mapView:(MKMapView *)mapMKMapView viewForAnnotation:      (id<MKAnnotation>)annotation
{
MKPinAnnotationView *MyPin=[[MKPinAnnotationView alloc] initWithAnnotation:annotation      reuseIdentifier:@"current"];
MyPin.pinColor = MKPinAnnotationColorPurple;

UIButton *adverButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[adverButton addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];

MyPin.rightCalloutAccessoryView = adverButton;
MyPin.draggable = YES;
MyPin.highlighted = YES;
MyPin.animatesDrop  = TRUE;
MyPin.canShowCallout  = YES;

return MyPin;
}

-(void)button:(id)sender
{
  //mapLabel.text =  @"Here is the chosen ann title";
}

0 个答案:

没有答案