我试图弄清楚为什么轨迹栏按钮不会将地图移回用户当前位置。它只是变成等待的旋转轮(下图),地图也不会移动。谢谢。
下面是我的部分代码。那里的坐标是针对市中心的,但我已经将模拟器的位置设置到了另一个地方,所以如果我点击轨迹栏按钮,我希望能移到那里。
- (void)viewDidLoad
{
[super viewDidLoad];
[self focusMap];
self.mapView.showsUserLocation = YES;
}
- (void) focusMap
{
CLLocationCoordinate2D coord = { -33.882365, 151.211025 };
MKCoordinateSpan span = {0.005,0.005};
MKCoordinateRegion region = {coord, span};
[mapView setRegion: region animated: YES];
MKUserTrackingBarButtonItem* trackerButton = [[MKUserTrackingBarButtonItem alloc] initWithMapView: self.mapView];
self.navigationItem.rightBarButtonItem = trackerButton;
[trackerButton release];
mapView.zoomEnabled = YES;
}