Reputation: 666
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
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
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
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