Cybernetic
Cybernetic

Reputation: 13334

Detail Disclosure Button on MapView Callout will not respond to tap

I would like to have another view loaded when I tap on the disclosure button in my map callout.

I added the button to the callout using the following in the initWithAnnotation method of my AnnotationView implementation file (I am only showing the relevant code):

- (id)initWithAnnotation:(id<MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier

{

 self.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];

}

I also added the following controllTapped method to my MapViewController implementation file for detecting when the disclosure button has been tapped:

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

{

    DetailViewController *dvc = [[DetailViewController alloc] init];
    [self.navigationController pushViewController:dvc animated:YES];



}

I also created a new detailedDisclosure class with an .XIB for a UI. This is the view I want to load when the user taps the disclosure button.

Why, then, does nothing happen when the user taps the disclosure button?

Upvotes: 0

Views: 493

Answers (2)

viral
viral

Reputation: 4208

You have to use MKMapView delegate method for this purpose like following, for identifying your CustomAnnotationClass:

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
    id <MKAnnotation> annotation = [view annotation];
    if ([annotation isKindOfClass:[CustomAnnotationClass class]])
    {
        DetailViewController *dvc = [[DetailViewController alloc] init];
        [self.navigationController pushViewController:dvc animated:YES];
    }
}

Let me kno, If you get it to work.

Upvotes: 0

Manu
Manu

Reputation: 4750

UIButton *btnGo = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[btnGo addTarget:self action:@selector(goToLocation:) forControlEvents:UIControlEventTouchUpInside];
pinView.rightCalloutAccessoryView=btnGo;


-(void) goToLocation:(UIButton *) sender
{
}

Upvotes: 1

Related Questions