Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As your method is never got invoked, you should do:</p> <pre><code>- (void)mapView:(MKMapView *)aMapView regionDidChangeAnimated:(BOOL)animated { [aMapView removeAnnotation:[self point]]; mkShape.coordinate = aMapView.centerCoordinate; [aMapView addAnnotation:mkShape]; } </code></pre> <p>And you should create your MKAnnotationView properly. You need create two properties in .h file first (for performance reason):</p> <pre><code>MKPointAnnotation *mkShape; MKAnnotationView *annotationView; </code></pre> <p>then use the code below to create your MKPointAnnotation</p> <pre><code>- (void)createShape { if (!mkShape) { mkShape = [[MKPointAnnotation alloc] init]; mkShape.title = nil; mkShape.subtitle = @"test description"; } } - (id &lt;MKAnnotation&gt;)point { [self createShape]; // Make sure to check if this is an MKPointAnnotation. MKOverlays also // conform to MKAnnotation, so it isn't sufficient to just check to // conformance to MKAnnotation. if ([mkShape isKindOfClass:[MKPointAnnotation class]]) return (id &lt;MKAnnotation&gt;)mkShape; return nil; } - (MKAnnotationView *)annotationView { if (!annotationView) { id &lt;MKAnnotation&gt; annotation = [self point]; if (annotation) { MKPinAnnotationView *pin = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:nil]; pin.canShowCallout = YES; pin.animatesDrop = YES; pin.draggable = NO; annotationView = pin; } } return annotationView; } - (MKAnnotationView *)mapView:(MKMapView *)aMapView viewForAnnotation:(id &lt;MKAnnotation&gt;)annotation { if ([annotation isEqual:mkShape]) { return [self annotationView]; } return nil; } </code></pre> <p>At the end, don't forget to release your properties.</p> <pre><code>- (void)dealloc { [annotationView release]; [mkShape release]; [super dealloc]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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