为什么我的用户位置总是在中心?

我在我的应用程序中有一张地图,当地图打开时,我设置了中心用户的位置。 我已经使用这个代码:

map.delegate=Self; ...... -(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation { MKCoordinateRegion mapRegion; mapRegion.center = self.mapView.userLocation.coordinate; mapRegion.span = MKCoordinateSpanMake(0.5, 0.5); //Zoom distance [self.mapView setRegion:mapRegion animated: YES]; } 

但是当我移动地图时,它回到用户的位置。 我怎样才能免费进入我的地图,无需顾虑用户的位置?

这是因为每当用户的位置发生变化时都要重置位置。 你应该只做一次,例如

 -(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation { if (self.centerToUserLocation) { MKCoordinateRegion mapRegion; mapRegion.center = self.mapView.userLocation.coordinate; mapRegion.span = MKCoordinateSpanMake(0.5, 0.5); //Zoom distance [self.mapView setRegion:mapRegion animated: YES]; self.centerToUserLocation = NO; } } 

其中centerToUserLocation类似centerToUserLocation @property (nonatomic) BOOL centerToUserLocation