Fork me on GitHub

2/28/2011

[iOS] 更新地標後,調整地圖適當大小!

Under iOS 4.2.1, the mapView:didAddAnnotationViews: method is not being called when the user's location is updated

改用 (void)mapView:(MKMapView *)mv didUpdateUserLocation:(MKUserLocation *)userLocation

所以要在更新 user 位置後調整地圖至適當的大小:

- (void)mapView:(MKMapView *)mv didUpdateUserLocation:(MKUserLocation *)userLocation {
    MKCoordinateRegion region = 
        MKCoordinateRegionMakeWithDistance([userLocation coordinate], 250, 250);
    
[mv setRegion:region animated:YES];
}

參考 forums.bignerdranch.com • View topic - Whereami under iOS 4.2.1

...

No comments:

Post a Comment