我使用 MapKit 框架创建了一个简单的应用程序。当它启动时,用户位置被放大并显示。但是当我缩小并滚动地图时,它会在几秒钟后自动将其自身集中到用户位置。我怎样才能阻止这个?
在 m 文件中:
#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];
}
请帮我 :)
最好的问候米哈尔