我使用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];
}
請幫我:)
問候 米哈爾
謝謝ssteinberg,完美的作品:) – Michlish 2012-04-18 11:01:04