Harsh
Harsh

Reputation: 666

Call new view on the click of detail disclosure button

In my application I am using mapkit. All the time I have more than one annoatations on the map. In the callout i have placed the detailDisclosureButton. On the click of this button I want to load new viewController. How to do this?

Thanks in advance.

Upvotes: 0

Views: 3321

Answers (3)

visakh7
visakh7

Reputation: 26400

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id )annotation
{

    //Some code here
    pinView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];

    return pinView;
}

And make use of the following delegate method to get the button action

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
// code to show details view
}

Upvotes: 1

saadnib
saadnib

Reputation: 11145

In - (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id )annotation delegate add a disclosure button as -

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

and in its action method -

-(IBAction) infoButtonPressed:(id) sender
{
    DetailViewController *dvc = [[DetailViewController alloc] init];
    [self.navigationController pushViewController:dvc animated:YES];
}

Upvotes: 2

msgambel
msgambel

Reputation: 7340

I would check here: Modal View Controller Reference to see how to move from one view to another. When the detailDisclosureButton is pressed, set up the viewController you want to move to, and use the methods described in the link. Hope that helps!

Upvotes: 0

Related Questions