6
votes

We've seen an unexpected behaviour in one of our apps - one one screen we're showing annotations on a map view and the user can change the annotations on display by clicking a button.

When we rebuild the app with iOS7 the screen would freeze regularly, i.e. no more user input was possible on the MKMapView once the code below had been called several times (with different sets of annotations) - the view is embedded in both a tab bar and a nav controller and all of their UI elements still worked, but the mapview itself would not accept any user input (pinching/zooming).

The code that displays the annotations is here:


 [self.mapView removeAnnotations:self.mapView.annotations];

 for (MyObject *my in self.mydata)
 { 
   MyAnnotation *annotation = [MyAnnotationFactory createAnnotationFor:my];
   [self.mapView addAnnotation:annotation];
 }

 CLLocationCoordinate2D  mycenter;
 mycenter.latitude = -38.967659;
 mycenter.longitude = 172.873534;

 [self.mapView setRegion:MKCoordinateRegionMake(mycenter, MKCoordinateSpanMake(15, 18)) 
               animated:YES];

 [self.mapView setCenterCoordinate:mycenter];

What I found is that by setting the region without animating it, i.e. by changing the above code to

 [self.mapView setRegion:MKCoordinateRegionMake(mycenter, MKCoordinateSpanMake(15, 18)) 
               animated:NO];

the problem goes away and the MKMapView behaves nicely on iOS7 as well.

If you have an idea as to why this is happening, and why it is happening only in iOS7 and not for earlier versions, I'd appreciate the clarification.

2
I've experienced the exact same problem. Unfortunately I haven't found a solution yet. - Jonathan
Are you suing threading at all? - latenitecoder

2 Answers

0
votes

Also, review your mapView:regionDidChangeAnimated: and mapView:regionWillChangeAnimated: methods. Implementing only one might work for you; one of those might not be needed for you to implement.

-1
votes

Try running the setRegion in a function from the main thread:

    [self performSelectorOnMainThread:@selector(animateMapRegion) withObject:nil waitUntilDone:NO];

-(void)animateMapRegion
{
    CLLocationCoordinate2D  mycenter;
    mycenter.latitude = -38.967659;
    mycenter.longitude = 172.873534;
    [self.mapView setRegion:MKCoordinateRegionMake(mycenter, MKCoordinateSpanMake(15, 18)) animated:animated];

}