如何获取单击的注释气泡

时间:2010-10-12 07:28:03

标签: iphone

我正在使用以下代码创建注释气泡按钮:

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

    MKPinAnnotationView *view = [mapView dequeueReusableAnnotationViewWithIdentifier:@"ParkPlaceMark"];
    if(!view)
    {
        view=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"ParkPlaceMark"];

    }

    UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    [rightButton addTarget:self action:@selector(ShowDetails:)forControlEvents:UIControlEventTouchUpInside];    
    view.rightCalloutAccessoryView = rightButton;

    [view setCanShowCallout:YES];

    return [view autorelease];
}

如何获取单击的注释,以便我转到带有id的详细信息屏幕,并根据该ID获取数据库记录以显示信息。

请帮忙。

2 个答案:

答案 0 :(得分:1)

您应该实现此委托方法:

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control

答案 1 :(得分:0)

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control 

 {

   appDelegate.mallIDStr=[dict valueForKey:@"Mall_Id"];

   self.tabBarController.selectedIndex = 2;

}

在上面的代码中,我点击显示商城位置的任何图钉

时保存商城ID