当我点击标签栏中的“地图”按钮时,它会拉出我的地图视图控制器,并在地图视图上显示用户的当前位置(我正在使用以下代码):
[mapview setShowsUserLocation:YES];
超级容易。但是,如果我希望地图自动放大用户的当前位置,我该怎么做(在 xCode 中)?
谢谢 :)
我想这就是你需要的
- (void)viewDidLoad
{
[super viewDidLoad];
self.mapView.showsUserLocation=YES;
self.mapView.delegate = self;
[self.mapView setUserTrackingMode:MKUserTrackingModeFollow animated:YES];
//some code
}
[mapview setUserTrackingMode:MKUserTrackingModeFollow];
这应该做你正在寻找的
MKCoordinateRegion region;
region = (MKCoordinateRegion){(current user location).location.coordinate, (current user location).locationCoordinateSpan};
[theMapView setRegion:region animated:NO/YES];