2012-04-18 163 views
0

我使用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]; 
} 

請幫我:)

問候 米哈爾

回答

0

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

+0

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

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

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

這使地圖以當前位置爲中心。

相關問題