Note that there are some explanatory texts on larger screens.

plurals
  1. POShowing the Pin Information by Default
    primarykey
    data
    text
    <p>I am working with <code>MKPinAnnotationView</code> annotations pins over a <code>MKMapView</code>. Into the view that I am developing, there is a map centered on a pin. When I call the view the pin drops down and if I make a click over it, it shows the annotation information (<code>canShowCallout = YES</code>). How I can get this callout just when I open the view? Without making a click over the annotation pin.</p> <p>Thanks for reading.</p> <p><strong>Edited:</strong></p> <p>I am using this code.</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; AddressAnnotation *annotation = [[[AddressAnnotation alloc] initWithCoordinate:self.currentAnnotationCoordinate] autorelease]; [self.mapView addAnnotation:annotation]; [self zoomCoordinate:self.currentAnnotationCoordinate]; } - (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; } - (void)mapViewDidFinishLoadingMap:(MKMapView *)theMapView { AddressAnnotation *annotation = [[[AddressAnnotation alloc] initWithCoordinate:self.currentAnnotationCoordinate] autorelease]; for (id&lt;MKAnnotation&gt; currentAnnotation in mapView.annotations) { if ([currentAnnotation isEqual:annotation]) { [mapView selectAnnotation:currentAnnotation animated:FALSE]; } } } </code></pre> <p><strong>Edited:</strong></p> <p>Calling <code>didAddAnnotationViews:</code> instead of <code>mapViewDidFinishLoadingMap:</code> (as aBitObvious has commented), it works fine.</p> <pre><code>- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views { id&lt;MKAnnotation&gt; myAnnotation = [self.mapView.annotations objectAtIndex:0]; [self.mapView selectAnnotation:myAnnotation animated:YES]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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