Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting Coordinates to UINavigationController into the showDetails Method
    text
    copied!<p>I have a map view with pins annotations into it. I need to pass to the detail view the coordinates of a pin when the user press the disclosure button of the pin information. How can I get the coordinates of the pin when I am into the showDetails method? I am using the next code.</p> <pre><code>- (void)showDetails:(id)sender { DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil ]; // HERE I NEED TO PASS THE COORDINATES OF THE PIN TO THE DETAILVIEWCONTROLLER. [self.navigationController pushViewController:detailViewController animated:YES]; [detailViewController release]; } - (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id &lt;MKAnnotation&gt;)annotation { // If it's the user location, just return nil. if ([annotation isKindOfClass:[MKUserLocation class]]) return nil; else { // Handles the other annotations. // Try to dequeue an existing pin view first. static NSString *AnnotationIdentifier = @"AnnotationIdentifier"; MKPinAnnotationView *pinView = (MKPinAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:AnnotationIdentifier]; if (!pinView) { // If an existing pin view was not available, creates one. MKPinAnnotationView *customPinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier] autorelease]; customPinView.animatesDrop = YES; customPinView.canShowCallout = YES; // Adds a detail disclosure button. UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; [rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside]; customPinView.rightCalloutAccessoryView = rightButton; return customPinView; } else pinView.annotation = annotation; } return nil; } </code></pre> <p>Thanks for reading.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload