2011-03-18 76 views
0

地圖視圖似乎無法跟蹤我的位置。如果當前位置正在移出地圖的可見區域,則地圖視圖不會自動平移。MapView不會跟蹤用戶位置

我在視圖上拖放地圖視圖,並在IB中將「顯示用戶位置」屬性設置爲true。

當我的視圖控制器的負載,我設置地圖視圖的區域如下

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    MKCoordinateRegion region; 
    region.center = aCoordinate; 
    region.span = MKCoordinateSpanMake(0.0625, 0.0625); 

    [mapView setRegion:region animated:YES]; 
} 

我也有以下方法,該方法將當前位置設置爲地圖的中心。

- (void)panToCurrentLocation:(id)sender 
{ 
    [mapView setCenterCoordinate:mapView.userLocation.coordinate animated:YES]; 

    mapView.showsUserLocation = YES; 
} 

當我移動時,地圖視圖仍然沒有跟蹤我的位置。如果當前位置移出可見區域,則地圖視圖不會平移。過了一段時間後,當前位置會從屏幕上移開,因爲地圖視圖不會自動平移。

我需要地圖視圖在我移動時自動平移。

回答

0

你打算從MKMapViewDelegate的mapView:didUpdateUserLocation:方法調用panToCurrentLocation:方法嗎?您是否確認在更新用戶位置時確實調用了它?

+0

不,它不會調用該方法。我的印象是地圖視圖會自動平移。我正在用小驅動來測試它。 – iJK 2011-03-18 03:26:54