以编程方式刷新mapview用户位置

时间:2012-04-28 12:51:30

标签: ios mapkit userlocation

我有一个带有地图视图的第一个视图控制器。 showUserLocation设置为YES,它完美地工作。然后我实现了方法:

- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation

在更新userLocation时执行一些操作。 它有效,但这是第一次。 如果我然后切换到另一个视图,然后我回到mapviewcontroller,不会再次触发didUpdateUserLocation,尽管用户位置显示在地图上。

有什么建议吗?

提前谢谢, 塞缪尔

1 个答案:

答案 0 :(得分:0)

对于iOS 5,请使用[mapView setUserTrackingMode:MKUserTrackingModeNone animated:NO]

其次 - 如果你正在打电话

- (void)mapView:(MKMapView *)aMapView
        didUpdateUserLocation:(MKUserLocation *)aUserLocation

方法

[aMapView setRegion:region animated:YES];

如果要将其移动到用户位置,请不要这样做。