tags:

views:

31

answers:

2

Hi guys,

I am creating annotation bubble buttons with the following code:

-(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];
}

How do i get that which annotation is clicked so that i go to details screen with the id and fetch the database record based on that id to show info.

Please help.

+1  A: 

You should implement this delegate method:

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

{

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

self.tabBarController.selectedIndex = 2;

} in above code i save mall id when click on any pin that show the mall location

GhostRider