-1

Hi I have this code to zoom in on the users location.

-(IBAction)getLocation{

mapview.showsUserLocation = YES;

MKCoordinateRegion region = { {0.0, 0.0}, {0.0, 0.0} };
region.center = mapview.userLocation.coordinate;
region.span.longitudeDelta = 0.1f;
region.span.latitudeDelta = 0.1f;

[mapview setRegion:region animated:YES];

}

On the first press of the button the map moves to coordinate 0,0, however on any subsequent presses it works as it should and takes the map to the users location. I cannot figure out why it does not work on the first go but works everytime after that??

4

1 に答える 1

1

これを試して:

- (IBAction)showCurrentLocation:(id)sender {
self.mapview.showsUserLocation=YES;
self.mapview.delegate = self;
[self.mapview setUserTrackingMode:MKUserTrackingModeFollow animated:YES];

}

于 2013-01-27T23:49:50.907 に答える