2010-10-12 29 views
0

我创建注释泡沫按钮用下面的代码:如何获得这些注释的气泡点击

-(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来显示信息。

请帮忙。

+0

没有质疑,相关型号,但不应该你只有在创建新视图时才会自动释放,而不是在出队时出现?应该崩溃... – Eiko 2010-10-12 07:31:54

+0

它没有崩溃...应用程序工作正常。 – Amarpreet 2010-10-13 02:37:53

回答

1

您应该实现此委托方法:

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

{ 

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

    self.tabBarController.selectedIndex = 2; 

} 
在上面的代码

我保存商场ID当点击,展示了商场位置的任何引脚