Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As mentioned, <code>mapViewDidFinishLoadingMap</code> is sometimes not called at all, especially if the map tiles are already cached, and sometimes it is called multiple times. </p> <p>I notice that when it is called multiple times at the last call all of the tiles are rendered. So I think you can get this to work if you set up a 2 second timer after the map starts changing. Disable interactions so that the map does not continue to change, and enable user interactions when the timer goes off. </p> <p>If <code>mapViewDidFinishLoadingMap</code> gets called reset the timer again for 2 seconds into the future. When the timer finally goes off, you should have a fully rendered map. </p> <p>You will want to consider the other callbacks such as <code>mapViewDidFailLoadingMap</code>. Also test this on a noisy connection, since 2 seconds may not be long enough if it takes a long time to fetch the tiles. </p> <pre><code>- (void)restartTimer { [self.finishLoadingTimer invalidate]; self.finishLoadingTimer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(mapLoadingIsFinished) userInfo:nil repeats:NO]; } - (void)mapLoadingIsFinished { self.finishLoadingTimer = nil; self.mapChanging = NO; self.view.userInteractionEnabled = YES; } - (void)mapViewDidFinishLoadingMap:(MKMapView *)mapView { if (self.mapChanging) { [self restartTimer]; } } - (void)startLookingForMapChange { assert(self.mapChanging == NO); if (self.mapChanging == NO) { self.mapChanging = YES; assert(self.finishLoadingTimer == nil); self.view.userInteractionEnabled = NO; [self restartTimer]; } } </code></pre>
 

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