Note that there are some explanatory texts on larger screens.

plurals
  1. POMKAnnotationView showing callout with no text
    primarykey
    data
    text
    <p><strong>Update</strong>:Michael got it right. Here is my solution:</p> <pre><code>- (void) connectNextCarOnMainThread:(id)annotation{ [self performSelectorOnMainThread:@selector(connectNextCar:) withObject:annotation waitUntilDone:YES]; } - (void) connectNextCar:(id)annotation{ Pin *pin = (Pin *)annotation; MKMapRect zoomRect = MKMapRectNull; MKMapPoint annotationPoint = MKMapPointForCoordinate(pin.coordinate); MKMapRect pointRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 3, 3); if (MKMapRectIsNull(zoomRect)) { zoomRect = pointRect; } else { zoomRect = MKMapRectUnion(zoomRect, pointRect); } [mapView setVisibleMapRect:zoomRect animated:YES]; [mapView selectAnnotation:pin animated:YES]; NSInteger currentIndex=[self.annotations indexOfObject:annotation]; if(currentIndex &lt; [self.annotations count]){ [self performSelector:@selector(connectNextCarOnMainThread:) withObject:[self.annotations objectAtIndex:currentIndex+1] afterDelay:5]; } } </code></pre> <p><br /></p> <hr> <p>I want to achieve a simple feature: center and select one of my annotations every X seconds. But I'm getting some strange behavior in my annotation callouts.</p> <p>Here is my code:</p> <pre><code>- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated{ if(self.movedToFitPins){ for(id &lt;MKAnnotation&gt; pin in self.annotations) [self.mapView addAnnotation:pin]; self.movedToFitPins = NO; [self performSelectorInBackground:@selector(fakeCarConnections) withObject:nil]; } } - (void) fakeCarConnections { for (Pin *annotation in self.annotations) { [NSThread sleepForTimeInterval : 10.0]; MKMapRect zoomRect = MKMapRectNull; MKMapPoint annotationPoint = MKMapPointForCoordinate(annotation.coordinate); MKMapRect pointRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 3, 3); if (MKMapRectIsNull(zoomRect)) { zoomRect = pointRect; } else { zoomRect = MKMapRectUnion(zoomRect, pointRect); } [mapView setVisibleMapRect:zoomRect animated:YES]; [mapView selectAnnotation:annotation animated:YES]; } } </code></pre> <p>So, what is happening is that I do focus on the Annotation, the callout bubble does open but with no text inside. If i click in the annotation, the callout opens up correctly with the text.<br /> Here is the catch: if I comment the sleepForTimeInterval line, the code works fine, but I only see the last annotation since it passes trough all the others.</p>
    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.
    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