Objective-c - 当地图更新自己时停止集中用户位置

问题描述:

我使用MapKit框架创建了一个简单的应用程序。当它开始时,用户位置被放大并显示。但是,当我缩小并滚动地图时,它会在几秒钟后自动将其自身集中到用户位置。我怎样才能阻止呢?Objective-c - 当地图更新自己时停止集中用户位置

在M-文件:[MapView的setUserTrackingMode:

#import "APPNAMEViewController.h" 
#import <MapKit/MapKit.h> 

@synthesize mapview; 

- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)aUserLocation  { 
    mapView.scrollEnabled = YES; 
    mapView.zoomEnabled = YES; 
    MKCoordinateRegion region; 
    MKCoordinateSpan span; 
    span.latitudeDelta = 0.005; 
    span.longitudeDelta = 0.005; 
    CLLocationCoordinate2D location; 
    location.latitude = aUserLocation.coordinate.latitude; 
    location.longitude = aUserLocation.coordinate.longitude; 
    region.span = span; 
    region.center = location; 
    [mapView setRegion:region animated:NO]; 
    [mapView setUserTrackingMode:MKUserTrackingModeNone animated:NO]; 
} 
- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    mapview = [[MKMapView alloc] 
      initWithFrame:CGRectMake(0, 
            44, 
            self.mapview.bounds.size.width, 
            self.mapview.bounds.size.height) 
      ]; 
    mapview.showsUserLocation = YES; 
    mapview.mapType = MKMapTypeStandard; 
    mapview.delegate = self; 
    [mapview setUserTrackingMode:MKUserTrackingModeNone animated:NO]; 

    [self.view addSubview:mapview]; 
} 

请帮我:)

问候 米哈尔

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

+0

谢谢ssteinberg,完美的作品:) – Michlish 2012-04-18 11:01:04

[mapView setRegion:region animated:NO]; //Changes the currently visible region and optionally animates the change. 

消除消除[mapView setRegion:region animated:NO]; :MKUserTrackingM odeNone animated:NO];

这使地图以当前位置为中心。