1
滾動我有,我用它來鎖定到用戶在地圖上的位置這兩個方法,它完美的作品後,縮放......解鎖在地圖
不過,我想它的工作原理太清楚了笑,每當我的用戶將地圖移動到地圖上的其他位置......它強制用戶返回當前位置所在的位置。
所以我想我的問題是,如何禁用用戶位置鎖定後,用戶在地圖上滾動。
- (void)viewDidLoad {
// more code here that i didn't post
[self.mapView.userLocation addObserver:self
forKeyPath:@"location"
options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld)
context:NULL];
}
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context {
if ([self.mapView showsUserLocation]) {
MKCoordinateRegion region;
region.center = self.mapView.userLocation.coordinate;
MKCoordinateSpan span;
span.latitudeDelta = 1; // Change these values to change the zoom
span.longitudeDelta = 1;
region.span = span;
[self.mapView setRegion:region animated:YES];
}
}