title: MKMapView not properly centered the first time it appears (but works thereafter)
body: <p>i have a master-detail app set up with the master being a UITableView containing a list of listings, each of which has a location (latitude and a longitude).  when the user taps a list item, they get a detail view comprising an MKMapView, with the relevant annotations on it.</p>
  
  <p>the code for setting the region to be displayed is below.  however, the first time the user taps an item on the list, the mapView shows half the world, centered apparently on 0,0.  the annotation that is placed (code not shown) is in the appropriate place, but the center and scale are all wrong.  if the user returns to the master list and taps the item again (or taps any other item), the map is properly centered and sized, and the code works v.  i cannot determine why the mapView is not responding the setRegion call properly the first time.</p>
  
  <p>the code below is in the viewWillAppear method of the detail controller, but the effect is the same if it is put in viewDidLoad, or even in the prepareForSegue method of the master view controller.  </p>
  
  <p>i also tried changing the initial declaration of region to different coordinates, thinking that might be the problem, but it isn't...the behavior is the same no matter what values i use when initializing region, or even if i don't set it's initial values.</p>
  
  <p>another SO user has asked the same question (<a href="https://stackoverflow.com/questions/13017461/cannot-get-uimapview-to-zoom-setregion-when-the-map-is-loaded-for-the-first-t">Cannot get UIMapView to &quot;zoom&quot;/setRegion: when the map is loaded for the first time</a>) but none of the answers solve the problem.</p>
  
  <p>fwiw, the detail view controller is declared to be an MKMapView delegate, and is assigned as the mapView's delegate, but i have not implemented any of the delegate methods (it is also an MKAnnotation delegate and i have implemented mapView:viewForAnnotation)</p>
  
  <p>any guidance about where i need to put this code, or what kind of delegate method i need to implement, so that it will cause the appropriate centering and scale the first time the mapView appears would be much appreciated.</p>
  
  <p>here's the code:   </p>
  
  <pre><code> CLLocationCoordinate2D coordinates = CLLocationCoordinate2DMake([self.listing.latitude doubleValue], [self.listing.longitude doubleValue]);
  MKPointAnnotation *selectedListingAnnotation=[[MKPointAnnotation alloc] init];
  selectedListingAnnotation.coordinate=coordinates;
  
  MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
  region.center = coordinates;
  region.span.longitudeDelta = 0.02f;
  region.span.latitudeDelta  = 0.02f;
  [self.mapView setRegion:region animated:YES];
  if (selectedListingAnnotation) {
      [self.mapView addAnnotation:selectedListingAnnotation];
  }
  </code></pre>