2

I have an MKMapView. To change the displayed region I use

[self.mapView setRegion:region animated:YES];

The strange is that on simulator the region is changed with animation, but on device the change is immediate and not animated.

I change the region after a long tap on the map...

This behavior drive me crazy and I can't able to solve it... Thanks...

Fry
  • 6,235
  • 8
  • 54
  • 93
  • You tested on ios 7 ? – VivienCormier Jul 04 '13 at 13:20
  • 1
    Have you tried doing a delay when you're trying to setRegion on device?, I'm thinking the map isn't loading fast enough. – soryngod Jul 04 '13 at 13:21
  • @soryngod can you explain better ? because I don't understand what you mean... – Fry Jul 04 '13 at 13:35
  • 1
    I know that the map doesn't load all the tiles in realtime and you might access the [self.mapView setRegion:region animated:YES] too fast , so you can try it like this: create another selector that contains this line of code and you can do [self performSelector:@selector(yourSelector) afterDelay:1.5f]; to see if setting the region a bit later will solve your problem. – soryngod Jul 04 '13 at 13:40
  • When the map recognize a long tap, I want change the region... so if I delay the change region the tap is a "long long tap". – Fry Jul 05 '13 at 08:06

3 Answers3

1

You need to slow down setRegion by using the following code

[self performSelector:@selector(setMapRegion) withObject:nil afterDelay:3.0];


-(void) setMapRegion
{
[self.mapView setRegion:region animated:YES];
}
Vinodh
  • 5,262
  • 4
  • 38
  • 68
1

If you load the map on device and iOS 6+ you'll experience a bit of delay till the tiles are loaded so the best thing to do is to try delaying the region change.

The map is not responsive even you set the animation it won't appear that clearly to you,it would look like it's not making any animation.

soryngod
  • 1,827
  • 1
  • 14
  • 13
0

MKMapView calls its delegate method mapViewDidFinishLoadingMap: once the map has loaded all the necessary tiles and is ready to use. You should call setRegion:animated: there.

Engin Kurutepe
  • 6,719
  • 3
  • 34
  • 64