Xcode Mapkit缩放到当前位置

时间:2012-08-02 14:18:03

标签: xcode location

我有一个基于地图的iphone应用程序,目前显示用户位置和通过json拉出的注释。我正在尝试创建一个按钮,使其缩放并以用户当前位置为中心。我找到了以下代码:

  • (IBAction)showCurrentLocation { [mapView setCenter:mapView.userLocation.coordinate animated:YES]; }

并了解这可以帮助我在任何地方粘贴此代码我都会收到错误。有没有人知道使这项工作的步骤/如果这是正确的方法?

谢谢!

1 个答案:

答案 0 :(得分:1)

这可能会对您有所帮助:

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